@@ -43,25 +43,28 @@ A newer version of EC Autoclicker ({}) is available.
4343Your current version is {}. Would you like to update now?
4444)" , verNumMatch.1, thisVersion), " Update" , " YesNo Icon ? 262144 "
4545 ) = " Yes" {
46- local downloadFilePath := ""
47- while ! downloadFilePath || FileExist (downloadFilePath)
48- downloadFilePath := A_ScriptDir " \" SubStr (A_ScriptName , 1 , - 4 ) " -new-" Random (100000 , 999999 ) " .exe"
46+ local downloadFileTargetName := " EC-Autoclicker" (A_Is64bitOS ? " _x64" : "" ) " .exe"
47+
48+ local downloadFileInitialPath
49+ Loop
50+ downloadFileInitialPath := A_ScriptDir " \" downloadFileTargetName " .new-" Random (100000 , 9999999 )
51+ Until ! FileExist (downloadFileInitialPath)
4952
5053 add_log(" Downloading file" )
5154
5255 try
53- Download " https://github.com/" GITHUB_REPO " /releases/latest/download/EC-Autoclicker.exe "
54- , downloadFilePath
56+ Download " https://github.com/" GITHUB_REPO " /releases/latest/download/" downloadFileTargetName
57+ , downloadFileInitialPath
5558 catch as err
5659 MsgBox " An error occurred in attempting to download the latest version of EC Autoclicker.`n`nMessage: " err.Message
5760 , " Update"
5861 , " Iconx 262144"
5962 else {
6063 add_log(" File downloaded" )
6164 Run " powershell.exe -WindowStyle Hidden -Command Start-Sleep -Seconds 1;"
62- . ' Remove- Item - LiteralPath " ' A_ScriptFullPath ' " ;'
63- . ' Rename - Item - LiteralPath " ' downloadFilePath ' " - NewName " ' A_ScriptName ' " ;'
64- . ' Start- Process - FilePath " ' A_ScriptDir '\EC-Autoclicker.exe /updated" '
65+ . " Remove-Item -LiteralPath ' " A_ScriptFullPath " '; "
66+ . " Rename-Item -LiteralPath ' " downloadFileInitialPath " ' -NewName ' " downloadFileTargetName " '; "
67+ . " Start-Process -FilePath ' " A_ScriptDir " \ " downloadFileTargetName " ' -ArgumentList ' /updated' "
6568 , , " Hide"
6669 ExitApp
6770 }
0 commit comments