Win10 - remember to execute as a specific user

5

I usually prefer to keep work and leisure accounts separated.

But let's say I need to access a program I installed on one from the other. The way I need to do it is by running the program as the respective other user (because otherwise, the stupid application won't recognise the license used to activate it and ask for another).

No big deal, I can shift-rightclick the application and run as the other by entering user name and password.

However, it'd be much more convenient if I could just left-click the application and it'd ask me for that specific user's password. Is there a way to manipulate the shortcut so it will do that?

(Ideally, of course, it wouldn't even ask for the password, but I sincerely doubt there's a way to set it up like that).

User1291

Posted 2017-05-22T18:03:18.487

Reputation: 366

@Twisty that worked, thank you. (Though I should mention it's not necessary to create a batch file for it.) Do you want to extend your comment into an answer? – User1291 – 2017-05-23T11:39:59.803

Answers

3

You can create a batch script that starts your program using the Runas command. For example:

@runas /user:someuser "C:\Program Files\Folder\MyProgram.exe"

Then create a shortcut to this script. When executed, it will prompt you for the password to the specified user account.

If you want to avoid the password prompt, add the /savecred switch:

@runas /savecred /user:someuser "C:\Program Files\Folder\MyProgram.exe"

The first time you execute this you'll be prompted for the account password, which will then be saved in the Windows Credential Manager. Subsequent launches of the command will not prompt for a password (unless you delete the entry from the Credential Manager).

Note that you can also directly enter above commands (without the @) into a shortcut's "target" property, either when editing an existing shortcut or when creating a new one. Windows will then automatically rewrite runas into the proper path s.t. the shortcut's target will read - for example -

C:\Windows\System32\runas.exe /user:someuser "C:\Program Files\Folder\MyProgram.exe"

I say Reinstate Monica

Posted 2017-05-22T18:03:18.487

Reputation: 21 477