Modify own file name

The code has no technical content. The principle is to run the program twice, judge it, and change the name.

code posted







.version 2

.Support library shell .Assembly


window Assembly_Startup window


. Subprogram__Startup window_created
. Local variable running path, text type
. Local variable own resources, byte set
. Local variable original path, text type
. Local The last path of the variable, text type


'This is method 1
' Method 2 is to run itself in memory, you can directly rename it. It is not as complicated as the following, but it is already running in memory. Renaming does not make much sense. This Baidu should be able to find my friend successfully. Don't write here


'! ! ! ! ! ! ! ! ! ! ! ! !
' In addition, a specific directory cannot be changed to 10. After changing to 10, an error will occur when writing to the file. I don't know the reason for the time being. The specific 10 is the system directory, but when writing to the file, it will be written to SysWOW64 for no reason.
' ! ! ! ! ! ! ! ! ! ! ! !


'Interpretation of temporary files
' tmp_1.bak: its own resource information is used to rename and output itself
' tmp_2.bak: its own running path does not include the file name
' tmp_3.bak: its own running path includes the file name
' tmp_4.bak: use To judge whether the name change is successful


, set the random number seed ()
. Judgment start (find text (take the running directory () + "\", take a specific directory (9), , true) = -1)
    run path = take the running directory () + "\"
    . Judgment start (whether the file exists (running path + "tmp_4.
        ' Information box ("The name has not been changed for the first time", 0, , )
        own resources = read in file (running path + get execution file name ())
        write to file (get specific directory (9) + "tmp_1.bak" , own resources)
        write to file (take specific directory (9) + "tmp_2.bak", to byte set (running path))
        write to file (take specific directory (9) + "tmp_3.bak", to byte set(run path + take execution file name()))
        run(take specific directory(9) + "tmp_1.bak", false, )
        end()
    . Default
        ' message box ("rename successfully deleted temporary file", 0 , , )
        file_delete(to text(read in file(take specific directory(9) + "tmp_3.bak")))
        delete file(take specific directory(9) + "tmp_1.bak")
        delete file(take specific directory(9) + "tmp_1.bak") specific directory (9) + "tmp_2.bak")
        delete file (take specific directory (9) + "tmp_3.bak")
        delete file (take running directory () + "\tmp_4.bak")
        ' write here _ start window Created code
        ' write here _ start window created code
        'Here write _ start window creation code
        ' here write _ start window created code
        ' here write _ start window created code
        ' write here _ start window created code
        ' write here _ start window created code
    .Judgment is


over.Default
    ' message box ("In the process of changing the name", 0, , )
    Running path = Get running directory() + "\" + Get execution file name()
    Original path = to text (read in file (take specific directory (9) + "tmp_2.bak"))
    own resource = read file (running path)
    last path = original path + to text (take random number (10000, 99999)) + ".exe"
    write to File (last path, own resources)
    write to file (original path + "tmp_4.bak", to byte set ("0"))
    run (last path, false, )
    end()
. Judgment end

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324644514&siteId=291194637