Notes from Daily Encounters with Technology RSS 2.0
 
# Wednesday, January 03, 2007

The functionality of the Run as context menu item is often an invaluable tool. The following two scenarios are probably the most common.

  • If you’re using a LUA account (which you always should) you can use it to run specific applications with administrative privileges.
  • If you’re a developer you can use it to test how you’re application behaves with different credentials.

The downside of this command is that unless you want to use the administrator’s account, you have to enter the desired username every single time which quickly becomes tedious.

You can work around that if use the Runas command. Its /user parameter allows you to set your desired username in advance. To avoid typing you can create a shortcut pointing to the following location:

C:\Windows\System32\runas.exe /user:MYCOMPUTER\MyUser MyApplication.exe

Apart from opening a command prompt for password instead of a nice GUI this should be a perfect solution, as long as you don’t want to run too many applications this way. Creating shortcuts for all of them can once again get tedious.

But fear not, there’s a solution for this as well; create your own context menu command by adding the following entry into the registry:

[HKEY_CURRENT_USER\Software\Classes\exefile\shell\Run as MyUser...\command]
@="C:\\Windows\\system32\\runas.exe /user:MYCOMPUTER\\MyUser \"%L\""

Of course you should replace MYCOMPUTER\MyUser with your desired username in both above examples; and MyApplication.exe in the shortcut with the path to your application. Use HKEY_LOCALMACHINE instead of HKEY_CURRENT_USER to add the command for all users not only for you.

Wednesday, January 03, 2007 9:54:16 PM (Central European Standard Time, UTC+01:00)  #    Comments [2] - Trackback
Software | Windows
Saturday, September 22, 2007 4:08:53 AM (Central European Daylight Time, UTC+02:00)
Hi there, please visit my page too. Thanks!
Monday, December 03, 2007 1:54:49 AM (Central European Standard Time, UTC+01:00)
This is great! One question: Is there any way around the authentication issue? I have a portal which requires a login/password. Am I out of luck?
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Sponsored Ads

About Me

Damir Arh

Microsoft Certified Professional

View Damir Arh's profile on LinkedIn

Profile for ExAmigan

ExAmigan

Twitter
Damir's Corner: Avoiding Queue Starvation in CruiseControl.NET http://goo.gl/fb/G52YB 1 day ago
RT @aleksj: From http://last.fm/robots.txt: Disallow: /harming/humans, Disallow: /ignoring/human/orders, Disallow: /harm/to/self #asimov 2 days ago
Eagle Eye on DVD was a pleasant surprise. It passed under my radar when it was first released. 5 days ago
Multiple RTM gadgets in iGoogle suddenly can't show different lists anymore http://digs.by/aD5AbJ 6 days ago
Notifications for new projects in CCTray are a nice new feature of #ccnet 1.5 7 days ago
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

All Content © 2010, Damir Arh, M. Sc. Send mail to the author(s) - Privacy Policy - Sign In
Based on DasBlog theme 'Business' created by Christoph De Baene (delarou)