diff --git a/Local-Client/Lib/Util.ahk b/Local-Client/Lib/Util.ahk index ec957af..5b1a692 100644 --- a/Local-Client/Lib/Util.ahk +++ b/Local-Client/Lib/Util.ahk @@ -84,10 +84,12 @@ Util_TempDir(outDir="") return tempDir } -Util_TempFile() +Util_TempFile(d:="") { + if ( !StrLen(d) || !FileExist(d) ) + d:=A_Temp Loop - tempName := A_Temp "\~temp" A_TickCount ".tmp" + tempName := d "\~temp" A_TickCount ".tmp" until !FileExist(tempName) return tempName } diff --git a/Local-Client/Package_Installer.ahk b/Local-Client/Package_Installer.ahk index 9e28e58..fca29a4 100644 --- a/Local-Client/Package_Installer.ahk +++ b/Local-Client/Package_Installer.ahk @@ -9,8 +9,8 @@ SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #Include Lib\Settings.ahk #Include Lib\Arguments.ahk -if (!A_IsAdmin) - ExitApp, % Install.Error_NonAdministrator +;if (!A_IsAdmin) +; ExitApp, % Install.Error_NonAdministrator if (!args) ExitApp, % Install.Error_InvalidParameters diff --git a/Local-Client/Package_Lister.ahk b/Local-Client/Package_Lister.ahk index 0597578..e245421 100644 --- a/Local-Client/Package_Lister.ahk +++ b/Local-Client/Package_Lister.ahk @@ -652,10 +652,16 @@ Install: ; http://support.microsoft.com/kb/830473 ;Assuming approximately 50 each file path, should be around 114 packages with "|" delimiters - ecode:=Admin_run("Package_Installer.ahk",Install_packs) - if (ecode=="NOT_ADMIN") { - Gui -Disabled - return + ;Changing Install folder will added in the future + if (isAdminRunAs_Needed(Settings.StdLib_Folder)) { + ecode:=Admin_run("Package_Installer.ahk",Install_packs) + if (ecode=="NOT_ADMIN") { + Gui -Disabled + return + } + } else { + Runwait "Package_Installer.ahk" "%Install_packs%",,UseErrorLevel + ecode := ErrorLevel } ;Update "Installed" list - full-blown list update @@ -747,10 +753,16 @@ Remove: ; http://support.microsoft.com/kb/830473 ;Assuming approximately 50 each file path, should be around 114 packages with "|" delimiters - ecode:=Admin_run("Package_Remover.ahk",Remove_packs) - if (ecode=="NOT_ADMIN") { - Gui -Disabled - return + ;Changing Install folder will added in the future + if (isAdminRunAs_Needed(Settings.StdLib_Folder)) { + ecode:=Admin_run("Package_Remover.ahk",Remove_packs) + if (ecode=="NOT_ADMIN") { + Gui -Disabled + return + } + } else { + Runwait "Package_Remover.ahk" "%Remove_packs%",,UseErrorLevel + ecode := ErrorLevel } ;full-blown list update @@ -820,3 +832,15 @@ Admin_run(program, argument) { return ErrorLevel } +isAdminRunAs_Needed(dir) { + if A_IsAdmin + return false + else { + tmpfn := Util_TempFile(dir) + FileAppend,__ASPDM_ADMIN_TEST__,%tmpfn% + if !(e:=ErrorLevel) + FileDelete,%tmpfn% + return e + } +} + diff --git a/Local-Client/Package_Remover.ahk b/Local-Client/Package_Remover.ahk index c8f6e1d..55ce6a4 100644 --- a/Local-Client/Package_Remover.ahk +++ b/Local-Client/Package_Remover.ahk @@ -9,8 +9,8 @@ SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #Include Lib\Settings.ahk #Include Lib\Arguments.ahk -if (!A_IsAdmin) - ExitApp, % Install.Error_NonAdministrator +;if (!A_IsAdmin) +; ExitApp, % Install.Error_NonAdministrator if (!args) ExitApp, % Install.Error_InvalidParameters