Skip to content

Commit f23be91

Browse files
authored
Actually fixed the self-updating mechanism
1 parent 32dfcaf commit f23be91

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

EC-Autoclicker.ahk

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
;@Ahk2Exe-SetCompanyName Expertcoderz
77
;@Ahk2Exe-SetDescription EC Autoclicker
8-
;@Ahk2Exe-SetVersion 1.0.1
8+
;@Ahk2Exe-SetVersion 1.0.2
99

1010
FILE_EXT := ".ac-profile"
1111
REG_KEY_PATH := "HKCU\Software\Expertcoderz\Autoclicker"
@@ -852,20 +852,24 @@ Your current version is {}. Would you like to update now?
852852
MsgBox "An error occurred in attempting to download the latest version of EC Autoclicker.`n`nMessage: " e.Message
853853
, "Update", "Iconx 262144"
854854
else {
855-
add_log("Running downloaded file and exiting")
856-
Run A_ScriptDir "\" DOWNLOAD_FILE_NAME ' /replace:"' A_ScriptFullPath '"'
855+
add_log("File downloaded")
856+
Run "powershell -windowstyle Hidden -command start-sleep 1;"
857+
. 'remove-item " ' A_ScriptFullPath ' ";'
858+
. 'rename-item " ' A_ScriptDir "\" DOWNLOAD_FILE_NAME ' " EC-Autoclicker.exe;'
859+
. 'start-process "' A_ScriptDir '\EC-Autoclicker.exe /updated"'
857860
ExitApp
858861
}
859862
}
860863
}
861864

862865
if A_IsCompiled {
863-
if A_Args.Length > 0 && RegExMatch(A_Args[1], "^/replace:.+$") {
866+
if A_Args.Length > 0 && A_Args[1] = "/updated" {
864867
RegWrite A_NowUTC, "REG_DWORD", REG_KEY_PATH, "LastUpdateCheck"
865-
FileMove A_ScriptFullPath, A_ScriptDir "\" SubStr(A_Args[1], 8), true
866868
MsgBox "EC Autoclicker has been updated successfully.", "Update", "Iconi 262144"
867-
} else if RegRead(REG_KEY_PATH, "AutoUpdate", false) && A_NowUTC - RegRead(REG_KEY_PATH, "LastUpdateCheck", 0) >= 604800
869+
} else if RegRead(REG_KEY_PATH, "AutoUpdate", true) && A_NowUTC - RegRead(REG_KEY_PATH, "LastUpdateCheck", 0) >= 604800 {
870+
add_log("Automatically checking for newer version")
868871
CheckForNewerVersion(false)
872+
}
869873
}
870874

871875
Loop {

0 commit comments

Comments
 (0)