The ‘Run as administrator’ option on a File Context Menu is only available on certain file types by default, and files are not one of them.

However, by doing a quick registry modification we can enable the ‘Run as administrator’ option o the file context menu.

My problem: We use software where an additional tool is included to switch the license type (network vs. This tool saves it's settings to the HKLM registry hive and our users do not have admin privileges so we need to think about a solution.

vbscript runas for validating credentials-7vbscript runas for validating credentials-75

This command enables one to run a command in the context of another user account.

One example scenario where this could be useful is: Suppose you have a normal user account and an administrator account on a computer and currently you are working from the normal user account.

Instead, you can do the same by simply using command and by providing administrator login id and password.

Let’s see the syntax of runas command with some examples.

Exec Query("SELECT * FROM Win32_Process",,48) For Each obj Item in col Items Wscript. I ran the script above and compared the results to task manager with the following results: As you can see, the script successfully showed the Command Line property for the currently logged on user However, the test script failed to show the Command Line property for the process running as administrator: By re-running the test script with elevated privileges, the script now successfully shows the Command Line property for the wscript process running as Administrator.

Now that I have successfully demonstrated the need to run a script elevated on a local machine, you might be wondering what happens when you the test script on a remote machine.' ' * This script has been tested on Win7 Enterprise 64bit and Win8 Enterprise 64bit only ' ' * If you find any errors or improvements, please let me know... Shell Execute(str Cur Dir & "\lsrunase.exe", str Param, "", "", 1) Else 'running the second time with (hopefully) correct credentials If Not Is Elevated Then ' We do not have elevation yet, so re-execute with elevation Call o Shell App. ' ' * As usual, if you decide to execute this script the author cannot be held ' responsible for any malfunctions, data corruption or unintended functionality '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' CHANGE THE FOLLOWING PARAMETERS TO YOUR OWN VALUES '------------------------------------------------------------------------------ Const str Domain="CONTOSO" Const str User="svclocaladmin" Const str Passwd=" ld/m/4L Lrag6ir Tt1Ag GE=" Const str Command="c:\some\path\name\program.exe" '------------------------------------------------------------------------------ ' DO NOT EDIT ANYTHING BELOW THIS LINE! Script Full Name) 'shortpath is needed because lsrunase does not support double escaping of quotation marks str Script Name = o Fso. Shell Execute("wscript.exe", str Script Name & " //b proceed", "", "runas", 0) Else ' In this section the command gets executed Call o Shell App. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.As most of you know Windows UAC can be a real pain in the a**.Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose.