Wednesday, May 06, 2009

How to "RunAs" a .bat or .msi file #tweetatech

We enjoy our ability to "RunAs" an executable file at work so we don't have to log out any users. We want more. We want to be able to do the same to .MSI and .Bat files too across the whole domain.
Here's how.

1. Create a .reg file and put this in it:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\batfile\shell\runas\command]
@="\"%1\" %*"

[HKEY_CLASSES_ROOT\Msi.Package\shell\runas]
@="Install &as..."

[HKEY_CLASSES_ROOT\Msi.Package\shell\runas\command]
@="msiexec /i \"%1\""

(example: \\shareddrive\runasfix.reg)

2. Create a .bat file that calls your new .reg file.

3. Put the .reg file on a shared folder. and the .bat file on your C:\ drive. (example: C:\runasfix.bat)

4. Create a .txt file of all the computer names you want this to run on in a column. (example: allpcs.txt)

5. Use psexec to push and launch your .bat to all of the computer in your list.
(example: psexec @"c:\allpcs.txt" -s -u ADMINISTRATOR@DOMAIN.COM -p PASSWORD -c -f -d -high c:\runasfix.bat

6. Sit back and enjoy!

2 comments:

  1. Winxp tested. Not sure about Vista and 7 yet. Will test on those too.

    ReplyDelete
  2. BTW: if you do not know what a registry is or does, do not do this. If you do not know what psexec is, do not do this.
    This hack is intended for domain admins only.

    ReplyDelete

Sociable


txtDrop.com