Run applications with preselected user credentials

The functionality of the Run as context menu item is often an invaluable tool. The following two scenarios are probably the most common.

  • If you’re using a LUA account (which you always should) you can use it to run specific applications with administrative privileges.
  • If you’re a developer you can use it to test how you’re application behaves with different credentials.

The downside of this command is that unless you want to use the administrator’s account, you have to enter the desired username every single time which quickly becomes tedious.

You can work around that if use the Runas command. Its /user parameter allows you to set your desired username in advance. To avoid typing you can create a shortcut pointing to the following location:

C:\Windows\System32\runas.exe /user:MYCOMPUTER\MyUser MyApplication.exe

Apart from opening a command prompt for password instead of a nice GUI this should be a perfect solution, as long as you don’t want to run too many applications this way. Creating shortcuts for all of them can once again get tedious.

But fear not, there’s a solution for this as well; create your own context menu command by adding the following entry into the registry:

[HKEY_CURRENT_USER\Software\Classes\exefile\shell\Run as MyUser...\command]
@="C:\\Windows\\system32\\runas.exe /user:MYCOMPUTER\\MyUser \"%L\""

Of course you should replace MYCOMPUTER\MyUser with your desired username in both above examples; and MyApplication.exe in the shortcut with the path to your application. Use HKEY_LOCALMACHINE instead of HKEY_CURRENT_USER to add the command for all users not only for you.

Avtor: Anonymous, objavljeno na portalu SloDug.si (Arhiv)

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.