2

I am looking for a runas alternative.

Is it possible to set up a particular application to ALWAYS RUN under a different account?

This is very different from defining a short-cut that does a run-as (there are disadvantages to this which I am trying to prevent).

I want to tell the system that if you run Nitro, it should run as a different user.

The short cut definition method won't work well for me because he would then have to run the short cut, then browse out to the file, and he would lose the ability to simply double click on the pdf and have Nitro automatically open up that pdf (I want to continue to be able to automatically open up a pdf that the user double-clicked on, but, it should always run as a different user in Nitor--the default pdf program).

Folks, don't down-vote this just because the answer might be "No, its not possible". I think that it might not be possible, but i have been surprised before (to my delight, and yet still down-voted for asking a valuable question). If there is an answer to this, it would be very valuable.

I'm actually using Windows 7, but if it is possible on 10, then I will consider an upgrade.

Michael Frank
  • 8,091
  • 3
  • 43
  • 54
Kam
  • 121

2 Answers2

1

There is a way to do this but you'l have to get comfortable with some registry hacking. I'll outline it step-by-step:

  1. Launch the Registry Editor (regedit.exe) and expand HKEY_CLASSES_ROOT. This key is where Windows records all file type associations and how it knows which program to open when you double-click a file.
  2. Locate the .pdf key and make a note of the (Default) entry on the right. This will be the name of the application ID that is associated with PDF files on your system. I have Acrobat installed on my system, so mine says AcroExch.Document.2017. Yours may say something different if Nitro is the default program for opening PDFs.

Screenshot showing the .PDF file association

  1. Scroll down to locate the key with the name you identified above. Note that we're still looking at HKEY_CLASSES_ROOT. Also note, there will probably be lots of keys with very similar names. You must match the name exactly.
  2. Drop down that key and go to shell -> Open -> command as shown below. The (Default) value is the command that Windows will execute when you open (i.e. double-click) the file.

Screenshot showing the Open command line

  1. You can put whatever command you want in here. Note that in my example, the command shows the full path to the .EXE file, followed by an argument (the name of the file):

    "C:\Program Files (x86)\Adobe\Acrobat Reader 2017\Reader\AcroRd32.exe" "%1"
    

    On my system, I would change it to:

    runas /user:<user> "\"C:\Program Files (x86)\Adobe\Acrobat Reader 2017\Reader\AcroRd32.exe\" \"%1\""
    

    Where <user> would be the account name.

That's it. You can close Registry Editor and you're done.

NOTE the kung-fu I had to do with the quotation marks in step 5. This is important that you get this right. The command to open PDFs on my computer is no longer AcroRd32.exe, it's runas.exe. Runas.exe only accepts one argument -- the full command line to be executed as if you had typed it from a command prompt. Since this string has spaces in it, the whole thing must be wrapped in quotes. And since the quoted string itself also has quotes in it (because the file name may have spaces in it), those quotation marks must be escaped as string literals.

Wes Sayeed
  • 14,102
0

I think that since can be done by replacing the executable of the application by a script that does a RunAs command.

This can be any script or a script compiled as executable and given the same name.

If you would rather not replace the executable, you can write an additional script such as .bat or .cmd and place it in the same folder as the .exe. You will run here into the problem of Windows preferring to run .exe before these types.

You may change the precedence order by modifying the PATHEXT environment variable, whose default value is .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC, so as to advance the precedence of your chosen suffix before that of .exe.

For information on PATHEXT see the answers of answer1 and answer2.

harrymc
  • 498,455