izzzy Posted May 30, 2018 Posted May 30, 2018 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? #RequireAdmin Run ('C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe') WHEN ATTEMPTING TO RUN AS ADMIN no DICE #RequireAdmin RunAsWait('ADMIN', 'DOMAIN', 'PASSWORD', 0, 'C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe') #RequireAdmin RunAs('ADMIN', 'DOMAIN', 'PASSWORD', 0, 'C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe') #RequireAdmin RunAsWait('LocalAccount', @ComputerName, 'PASSWORD', 0, 'C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe') #RequireAdmin RunAs('LocalAccount', @ComputerName, 'PASSWORD', 0, 'C:\Users\TEST\Desktop\Auto It Sripts\JVUninstall.exe')
TheXman Posted May 31, 2018 Posted May 31, 2018 (edited) 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 May 31, 2018 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
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