Jump to content

Recommended Posts

Unable to Run a executable file as administrator or different account. I have tried nearly all combinations in these forums but have fallen short. Right now when I run a simple script like the following it works, because I'm logged in as administrator. The challenge is that I will be running these scripts on user PCs with no admin credentials. Any help?

Run ('C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe')



RunAsWait('ADMIN', 'DOMAIN', 'PASSWORD', 0, 'C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe')

RunAs('ADMIN', 'DOMAIN', 'PASSWORD', 0, 'C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe')

RunAsWait('LocalAccount', @ComputerName, 'PASSWORD', 0, 'C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe')

RunAs('LocalAccount', @ComputerName, 'PASSWORD', 0, 'C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe')

Link to post
Share on other sites

Why did you post this to "Projects and Collaboration"?  This seems more like a windows client or general help issue.

There are numerous posts related to running scripts as an admin.  There are also a few different ways to do it.  Each method has its own set of prerequisite requirements and advantages.

All of your examples imply that you are using the #RequireAdmin directive.  If UAC is enabled and is configured in its default state, then the #RequireAdmin directive will trigger the UAC prompt whether the user account the script is running under is an admin or not.  There are other methods of running with an admin token that do not use the #RequireAdmin directive, such as the ShellExecute/ShellExecuteWait command with the "runas" verb.  There are also ways to run without getting the UAC prompt, if the user account the script is running under is a local admin.

One of the main issues with using the RunAs command is that the user account that you use HAS to have read/execute and possibly write privileges to the working directory.  By default, that is the value of the @systemdir macro.  That means that unless you have previously change the ACLs on the target machine, Administrators do not have access to user profile folders and several other folders on remote workstations.  Unless you use the actual Local Administrator account, most attempts to use RunAs() will fail with Access Denied.  The Local Administrator account is usually disabled, especially if other local admin accounts have been defined.

Being able to successfully run scripts on remote clients really depends upon how much control you have over the environment.  It also depends upon whether your users are local admins of their workstations and if you are running under those accounts.  If they are not, it gets a little more tricky but is possible.  You just have to make sure that you have an account on the machine that is an admin and that account has to have been given read/execute/write privileges to the folder in which the script is run.

Like I said, there are several posts.  Do a little research.  Afterwards, if you have questions, post them.


Edited by TheXman
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...