The Wire Making Smartphones Smarter

13Jan/110

Run as different user

ShellRunas

If you've ever had to run a program as a different user than the one you were logged in as you might have been surprised the first time you used Vista or Windows 7 to not see the friendly "Run as different user..." option in your context menu.

On Vista, this option was removed completely. On Windows 7 you have to hold Shift while right-clicking to get it to show up. This is not obvious and can be irritating.

I recently came across a tool by Sysinternals (now Microsoft) called ShellRunas.  Go get it. To restore your context menu do this:

  1. Extract the ShellRunas.exe to your C:\Windows\System32 directory
  2. Open a command prompt (as Administrator), type:
    ShellRunas.exe /reg

Your context menu has been restored!  That's pretty awesome by itself, but something I like to do is use it to create shortcuts.

A common occurrence for me is the need to run Microsoft SQL Management Studio as a different user to login to a server that only accepts Windows Authentication. This is a classic Run as different user scenario, but I can't tell you how many times I have opened it up and tried to connect only to remember I have to restart the whole program with the Run as different user option.  So I created a shortcut by doing this:

  1. Copied my current shortcut to Management Studio and pasted it to create a new one
  2. Right-Clicked on the shortcut and selected Properties
  3. Changed the target to:
    C:\Windows\System32\ShellRunas.exe "C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe"
    (your path may be different)

Now when I run that shortcut I am automatically prompted for my credentials!  But there is another feature of ShellRunas that can make your shortcut even better.  If I change the target setting from above to this:
C:\Windows\System32\ShellRunas.exe /netonly "C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe"

That /netonly section uses the alternate credentials only on remote calls.  This means that in Management Studio (or whatever program) I can access all my documents (as long as they aren't mapped to a network share) and still be using the correct credentials when accessing the remote server!

Just a simple but effective tool that makes my job easier.

Bookmark and Share
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.