Damir Arh's Corner
Search
Categories
  Development
 .NET
 Batch
 C++
 SQL
 VB6
 Vista
 Web
 Win32
  Downloads
 Amiga
 Articles
 Presentations
 Sources
 Windows
  Personal
 Education
 Software
 Website
Archives
July, 2008 (1)
June, 2008 (1)
April, 2008 (2)
December, 2007 (1)
November, 2007 (3)
July, 2007 (4)
June, 2007 (1)
May, 2007 (2)
March, 2007 (3)
January, 2007 (1)
December, 2006 (4)
October, 2006 (5)
September, 2006 (3)
August, 2006 (2)
June, 2006 (8)
May, 2006 (5)
April, 2006 (1)
March, 2006 (4)
February, 2006 (3)
January, 2006 (3)
March, 2003 (1)
February, 2002 (1)
January, 2002 (2)
August, 2001 (1)
July, 2001 (1)
February, 2001 (1)
December, 2000 (1)
September, 2000 (1)
July, 2000 (1)
Other Sites
Potepanja v naravi (sl)
Picasa Web Albums (sl)
moj-album.com Gallery (sl)
Bolha.com Auctions (sl)
My Game Space
LinkedIn Public Profile
My GamerTag
Sponsored Links
Administration
Sign In
Wednesday, January 03, 2007

Run applications with preselected user credentials (Personal | Software)

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.

1/3/2007 9:54:16 PM (Central Europe Standard Time, UTC+01:00)  #  Comments [2]

9/22/2007 3:08:53 AM (Central Europe Standard Time, UTC+01:00)
Hi there, please visit my page too. Thanks!
halloween costume |hallow11eenAT NOSPAMhotmail dot com
12/3/2007 1:54:49 AM (Central Europe 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?
christmas nativity scene |nativity07AT NOSPAMlive dot com
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Blog Feeds
RSS 2.0 RSS 2.0
Atom 1.0 ATOM 1.0
Fellow Bloggers
 Andrej Tozon
 Dejan Sarka
 Dusan Zupancic
 Matevz Gacnik
 Miha Markic
Disclaimer
The content of this site are my own personal opinions and do not represent my employer's view in anyway. In addition, my thoughts and opinions often change, and as a weblog is intended to provide a semi-permanent point in time snapshot you should not consider out of date posts to reflect my current thoughts and opinions.

Powered by:
newtelligence dasBlog 1.8.5223.2

© 2008 Damir Arh, M. Sc. Send mail to the author(s)

Microsoft Certified Professional
Currently Reading
Currently Playing
Currently Watching