Print

Administrator Program Shortcut without Prompt

Applies to:
- Microsoft Windows 7 Enterprise
- User with Local Administrator Privileges (required for setup)


Why?
Our work has group policies and two of our programs, Visual Studio 2010 Ultimate (VS2010) and Business Intelligence Development Studio (BIDS), require elevated or administator rights/privileges when run. This is so that these programs can write back and forth to our C drive. If we don't run them as local administrators on the workstation, they error incessantly and never manage to do what you want them to do.


What?
I want to create a desktop shortcut that I can double-click and it will run the above programs in administrator mode without confirmation by the Windows operating system. At home this may not be a problem but this is intended for those in an office environment and we get prompted to login (with the same account as we're currently logged-in with???) instead of being able to just click on "Yes".


How?
The gist is that we're going to create a scheduled task (that won't be scheduled) and a shortcut to that task:
  1. Open the Task Scheduler (Start > Run... > Type taskschd.msc > OK) - You will need administrator rights for this step.
  2. Click on Create Task...
  3. Under the General tab,
    1. for "Name" give it a general name with no symbols/special characters and preferably no spaces (I tend to give it an all lowercase name with no spaces).
    2. tick the checkbox Run with highest privileges.
    3. set "Configure For" to Windows 7, Windows Server 2008 R2
  4. Under the Actions tab,
    1. Click on New...
    2. Leave "Action" as Start a program
    3. for Program/Script, Specify the command path which is usually %windir%\System32\cmd.exe
    4. Add arguments in format /c start "Task Name" "Full Path of Program", for example:
      copyraw
      /c start "VisualStudio2010" "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"
      1.  /c start "VisualStudio2010" "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" 
    5. for Start In..., I leave this blank but you could specify a working directory.
  5. OK the dialogs and close the Task Scheduler
  6. Right-click on an empty space on the desktop and select New > Shortcut
  7. Type in the task with the format schtasks /run /tn "task-name"
    copyraw
    schtasks /run /tn "VisualStudio2010"
    1.  schtasks /run /tn "VisualStudio2010" 
    and click on Next
  8. Give the shortcut a name to display as (eg. "Visual Studio 2010")
  9. Click on OK to complete your shortcut.
Additional: You can change the icon for the shortcut using the shortcut properties and browsing to the program it was created to run.


Related Link(s):

Further Notes
Location of Windows 7 Taskbar shortcuts (Pinned): %APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar. You can determine what %APPDATA% is by opening a command prompt and typing:
copyraw
echo %appdata%
  1.  echo %appdata% 


Category: Windows OS :: Article: 489