1

I am trying to have an app always run as another user. I know you can launch the app as another user via editing the shortcut but then when you double click a file it runs as you and not other user.

I have tried to put a bat file with the correct command line

@ runas /savecred /user:MYDOMAIN\myuser "C:\Program Files\Myapp\app.exe"

and set it as "default program" to open the file But then it does not open the file just the app as there is no callback to the original file.

Do you know of any way to pass the calling path/file to the bat file ? Or regedit the default runas user ?

I have carefully read what is said here regarding the /savecred but my case is on safe PC and just for myself for daily comfort. And the goal is really not to have to juggle shortcuts and credentials.

I am open to regedit/powershell/batch or other.

Thanks a lot for the help

  • You are not passing the file itself. Add a `%1` parameter in the registry on the call to the `.bat` file, and also append it at the end of the `runas` command. – harrymc May 29 '19 at 20:29
  • Hmmm there is definetly an improvement but is still does not behave as i the program was run natively. What do you mean adding the %1 in the registry ? Where would that be ? – Up_on_th_hill May 29 '19 at 21:26
  • How did you set it as default handler? – harrymc May 29 '19 at 22:01
  • Through the right clic, set as. But it seems to work with %1 it just cannot access assets that are in a user reserved place. Which might be logical but is not the behaviour when you run as with a shortcut. – Up_on_th_hill May 30 '19 at 12:25
  • So one problem is solved. Please give more details about the access problem. Does it happen if you use Run for the above `runas` command with the file-path as added parameter? – harrymc May 30 '19 at 12:40
  • Basically it seems that the service account that I impersonate cannot access any ressource that is stored in a personal user folder. Like if the impersonation was stronger that when you use a shift right click or change the shortcut to use runas. But overall I can work with that. It gives me a god solution for directly clicking on files. – Up_on_th_hill May 31 '19 at 12:30
  • I have added an answer, please correct it if you did it differently. If my answer has helped with the problem, please accept it (tick the V sign). – harrymc May 31 '19 at 15:37

1 Answers1

0

The command used lacks the parameter itself that contains the argument's file-path:

@ runas /savecred /user:MYDOMAIN\myuser "C:\Program Files\Myapp\app.exe" "%1"
harrymc
  • 455,459
  • 31
  • 526
  • 924