The issues with file path: I want to check for a file path, but may be unsure of what drive it is under. My computer has it located as "Z:/Employee Files" ... The computer I would be running the script on is "F:\Company Files\Employee Files
Getting the file path to be more dynamic if possible would be lovely. I have attempted using just the known string and wildcards "*\01 EMPLOYEE FILES\00 Me\(ect.)".
This code works as far as I have been using it:
The Code for the 2nd "updater" script.
Code: Select all
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
remove_Updater(*) {
my_File_Delete(A_Temp "\warlords_Script_Updater.ini")
my_File_Delete(A_Temp "\warlords_Script_Updater.exe")
return
}
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
my_File_Delete(path_to_Delete) {
try {
FileDelete(path_to_Delete)
}
}
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
OnExit(remove_Updater)
if (FileExist(A_Temp "\warlords_Script_Updater.ini")) {
script_Name := IniRead(A_Temp "\warlords_Script_Updater.ini", "script_to_Update", "the_Name")
script_Location := IniRead(A_Temp "\warlords_Script_Updater.ini", "script_to_Update", "working_Space")
if (FileExist("Z:\01 EMPLOYEE FILES\00 Me")) {
found_Location := "Z:\01 EMPLOYEE FILES\00 Me\Executables\" script_Name
} else if (FileExist("F:\Company Files\01 EMPLOYEE FILES\00 Me")) {
found_Location := "F:\Company Files\01 EMPLOYEE FILES\00 Me\Executables\" script_Name
} else {
found_Location := 0
}
if (FileExist(found_Location)) {
FileCopy(found_Location, script_Location, 1)
while (!FileExist(script_Location)) {
Sleep(50)
}
MsgBox(script_Name " has been updated.")
Run(script_Location)
} else {
MsgBox("No Updated File Available.")
Run(script_Location)
}
} else {
MsgBox("Update Failed.")
}
ExitApp()
Code: Select all
#SingleInstance Force
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
if (A_IsCompiled && !IsSet(ver_Now)) {
ver_Now := "1.0.0"
the_Name := "AIO_Suite"
check_for_update()
}
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;
check_for_update() {
global
if (FileExist("Z:\01 EMPLOYEE FILES\00 Me\Code\The Collector\CollectToggle\" the_Name "_version_Number.ini")) {
found_Location := "Z:\01 EMPLOYEE FILES\00 Me\Code\The Collector\CollectToggle\" the_Name "_version_Number.ini"
} else if (FileExist("F:\Company Files\01 EMPLOYEE FILES\00 Me\Code\The Collector\CollectToggle\" the_Name "_version_Number.ini")) {
found_Location := "F:\Company Files\01 EMPLOYEE FILES\00 Me\Code\The Collector\CollectToggle\" the_Name "_version_Number.ini"
} else {
found_Location := 0
}
if (FileExist(found_Location)) {
current := IniRead(found_Location, "version", "current")
if (ver_Now !== current) {
while (A_TimeIdle < 500) {
Sleep(1000)
}
msgResult := MsgBox("Update available for " the_Name ", continue update?", "", 4)
if (msgResult = "Yes") {
try {
FileDelete(A_Temp "\warlords_Script_Updater.ini")
}
FileAppend
(
"[script_to_Update]
the_Name=" the_Name ".exe
working_Space=" A_ScriptFullPath
), A_Temp "\warlords_Script_Updater.ini"
FileInstall("Z:\01 EMPLOYEE FILES\00 Me\Executables\warlords_Script_Updater.exe", A_Temp "\warlords_Script_Updater.exe", 1)
Run(A_Temp "\warlords_Script_Updater.exe")
ExitApp()
}
}
} else {
FileAppend
(
"[version]
current=" ver_Now "
)", found_Location
}
SetTimer(check_for_update,360000)
return
}
; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ; ------------------------- ;