Running an application ALWAYS as another user (not short cut based)

0

I need to be able to run Word, Excel, ect... as a different user. This has to also happen when you open a .docx, .doc, ect...

My guess would be to edit the registry and add a command in there so that on executing the .exe it launches as another user.

Is there a better way to do this?

Jason

Posted 2017-09-21T00:56:28.667

Reputation: 3 636

Answers

1

Yes. Write a batch file to set an argument as a variable. Then run the desired application with the runas or psexec command and pass the variable to the application as a parameter. Then set the batch file as the default application for the file type.

set arg1=%1
runas /user:<UserName> "C:\Program Files\GIMP 2\bin\gimp-2.8.exe" %1

The issue with runas would be you would need to enter the password every time. You may want to use psexec as you can script the password as well.

set arg1=%1
psexec -u user -p password "C:\Program Files\GIMP 2\bin\gimp-2.8.exe" %1

Out_Of_Names

Posted 2017-09-21T00:56:28.667

Reputation: 21

0

I think that when you start a process, the user it belongs to is the same as the user that owns the parent process. That is, if you start Command Prompt as Gandalf and then run Notepad.exe then you'll run Notepad as Gandalf, even if you're logged in as Sauron.

With this in mind, it sounds to me like what you want to do is run Windows Explorer as the user of your choice (using runas), and then anything you run through it will be run under the user you selected - that includes executables, shortcuts and files (when you "run" a file through Windows Explorer, it just runs the application it's associated with and passes the name of the file as an argument). Just be sure to kill Windows Explorer before you run it, otherwise it'll just open up some folder.

I'm afraid I can't test this since I only have one user account on my system.

Tomer Godinger

Posted 2017-09-21T00:56:28.667

Reputation: 551