Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to have two shortcuts to Visual Studio on my taskbar: one with default settings and a second modified to always run as admin.

I know I can manually start a copy with admin rights by right clicking on the shortcut and then right clicking on the name of the application and selecting Run as administrator...; but I'd like to automate the process when I need it (without impeding my ability to start VS without admin rights when I don't need them).

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

I have a dirty hack that worked for me:

  1. Create a non-admin shortcut to the VS IDE executable and pin it to the task bar
  2. Create a second shortcut to the same target and set its shortcut properties to run as Administrator: Properties -> Shortcut -> Advanced -> Run as administrator.
  3. Create a batch file next to the admin shortcut to call it. For example, if the shortcut is named "Admin": start "" "Admin.lnk"
  4. Create a shortcut to the batch file, and change the Target to call the batch file via cmd /C. For example: C:\Windows\System32\cmd.exe /C "C:\<Your Path>\admin.bat"
  5. Optionally, change the icon for the batch shortcut: Properties -> Shortcut -> Change Icon.... The following DLL has a small collection of icons to choose from if you're not picky: %SystemRoot%\System32\shell32.dll
  6. Pin the shortcut to the batch file to the task bar.

So the paths of your two pinned shortcuts are:

  • Shortcut w/o Admin => VS
  • Shortcut to CMD to run BAT => BAT to run CMD to run Shortcut => Shortcut with Admin => VS

Some notes:

  • Step 2: I had trouble with using 'Privilege Level' under Compatibility settings versus the Advanced Shortcut settings. As others have observed, there seems to be some relationship to the executable that is shared among shortcuts. Both of my shortcuts would be either admin or not. With step 2 you now have two independent shortcuts, but Windows 7 won't let you pin both as they have the same target.
  • Step 3: Windows 7 won't let you create a true shortcut to a shortcut. Instead it will replace it with a duplicate shortcut. If you attempt to manually change the target it will yell at you. Moving the call to the batch file allows us to create a "fresh" shortcut.
  • Step 4: Windows 7 won't let you pin a shortcut to a batch file, but will let you pin a shortcut to a CMD instance that calls a batch file.
share|improve this answer
    
The only caveats I have with your suggestion are that the shortcut shows up with the cmd.exe icon by default and that the command prompt window needed to be manually closed. The former problem was easily fixed by creating and assigning a custom icon (probably a good thing to do anyway for disambiguation). –  Dan Neely Dec 7 '12 at 20:57
1  
The window should go away if you change cmd /C "Admin.lnk" to in the batch file to start "" "Admin.lnk". I've updated my response to suggest this approach. –  Terrance Dec 10 '12 at 13:50
add comment

Go to devenv.exe and create two different shortcuts with different properties. Then pin both shortcuts to the taskbar.

share|improve this answer
    
Doesn't work. The second shortcut silently fails to pin itself. –  Dan Neely Dec 7 '12 at 18:02
    
This may be due to the fact that the admin/non admin setting is being stored on the executable not the shortcut itself; so as far as windows is concerned the two shortcuts actually are the same thing despite their different names. –  Dan Neely Dec 7 '12 at 18:12
    
Interesting. You could try actually duplicating devenv.exe and then pin them separately. You would want to be sure to update the exe if VS upgrades/patches occur. –  GaTechThomas Dec 8 '12 at 3:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.