08 February 2016

How to run an application as a different user

I often have the need to run applications with different credentials. For instance I may need to connect to a website that users Windows integrated authentication, but I need to use my admin account, not my normal logon to access this. Instead of logging off or switching users I simply created a batch script which launches IE with a different set of credentials.

runas /user:[domain]\[user account] "C:\Program Files (x86)\Internet Explorer\iexplore.exe \"[URL]\""

You can use the runas command to run any application you like, just substitute the values above.
Also note that doing as above will prompt you for your password when you run it, so it is best for interactive use. You can store your password in the batch script, but I would not recommend this.