Jump to content
Sign in to follow this  
cshbell

Permissions issues with FileExists

Recommended Posts

cshbell

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?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×