cshbell Posted November 19, 2007 Share Posted November 19, 2007 I'm creating a script that will be run by users with Administrator privileges:RunAsSet("Administrator", "DOMAIN", "password") If FileExists("C:\WINDOWS\$NtUninstallKB917013$\spuninst\spuninst.exe") Then Run("C:\WINDOWS\$NtUninstallKB917013$\spuninst\spuninst.exe /q /norestart") EndIf RunAsSet()I only want it to trigger if the package is actually on the computer, hence the If FileExists. however, the file that I need to use for determining whether or not the package is installed (spuninst.exe) is in a location that a user without Administrator privileges does not have access to. Therefore, the If FileExists assertion fails, because (I assume) the If FileExists is being executed with the user's default privileges and not the escalated privileges used by RunAsSet.So my question is, is there a way to perform the If FileExists check with escalated (e.g. Administrator-level) privileges? Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 19, 2007 Share Posted November 19, 2007 I'm creating a script that will be run by users with Administrator privileges: RunAsSet("Administrator", "DOMAIN", "password") If FileExists("C:\WINDOWS\$NtUninstallKB917013$\spuninst\spuninst.exe") Then Run("C:\WINDOWS\$NtUninstallKB917013$\spuninst\spuninst.exe /q /norestart") EndIf RunAsSet() I only want it to trigger if the package is actually on the computer, hence the If FileExists. however, the file that I need to use for determining whether or not the package is installed (spuninst.exe) is in a location that a user without Administrator privileges does not have access to. Therefore, the If FileExists assertion fails, because (I assume) the If FileExists is being executed with the user's default privileges and not the escalated privileges used by RunAsSet. So my question is, is there a way to perform the If FileExists check with escalated (e.g. Administrator-level) privileges? One quick way: Opt("RunErrorsFatal", 0) RunAsSet("Administrator", "DOMAIN", "password") $RET = RunWait(@ComSpec & ' /c DIR "C:\WINDOWS\$NtUninstallKB917013$\spuninst\spuninst.exe"') If ($RET = 0) And @error = 0 Then Run("C:\WINDOWS\$NtUninstallKB917013$\spuninst\spuninst.exe /q /norestart") EndIf RunAsSet() Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now