Execution of function on first time open only

Question:

Context:- I will convert my code to exe that’s why the code won’t be readable. I am trying to prevent copying of my paid software. in which I am using machine GUID as a Licence

Question: How to run a function only on a first-time startup? Here I have written the part of the code –


    result = _winreg.QueryValueEx(key, "MachineGuid")
    ID = str(result)
    
    licence_path = 'C:\Program Files\Common Files\System\read.txt'
    
    def first_time_open_only():           #
        file = open(licence_path, 'w')    #
        file.write(ID[2:38])              #These codes should only run only on first-time startup
        file.close()                      #of the software
                                          #
    first_time_open_only()                #
    
    with open(licence_path) as f:
        contents = f.read()
        if contents == str:
            pass
        else:
            root.destroy()
            
    root.mainloop()

I have tried increasing the value of a number each time the function is executed, but It wasn’t working and could not find the answer anywhere in the internet.

Asked By: Anonymous 70

||

Answers:

Context:- I will convert my code to exe that’s why the code won’t be readable. I am trying to prevent copying of my paid software. in which I am using machine GUID as a Licence.

result = _winreg.QueryValueEx(key, "MachineGuid")
ID = str(result)

licence_path = 'C:\Program Files\Common Files\System\read.txt'

def first_time_open_only():           #
    file = open(licence_path, 'w')    #
    file.write(ID[2:38])              #These codes should only run only on first-time startup
    file.close()                      #of the software
                                      #
first_time_open_only()                #

with open(licence_path) as f:
    contents = f.read()
    if contents == str:
        pass
    else:
        root.destroy()
        
root.mainloop()
Answered By: ANONYMOUS GAMER
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.