How to Add Create Elevated Shortcut to New Context Menu in Windows 10  

    How to Add Create Elevated Shortcut to New Context Menu in Windows 10

    How to Add Create Elevated Shortcut to New Context Menu in Windows 10

    Published by Category: Customization
    27 Jan 2021
    Designer Media Ltd

    How to Add Create Elevated Shortcut to New Context Menu in Windows 10


    When you open an application file with Run as administrator, you will get a UAC prompt for approval before the app is allowed to run with elevated rights.

    In addition, Windows will not allow elevated apps to run at startup by default.

    If you want to run an app as administrator (elevated) without getting a UAC prompt or at startup, then you can create an elevated task to run the application as a workaround to do so.

    This tutorial will show you how to add or remove create an Elevated Shortcut to the New context menu for all users in Windows 10.

    You must be signed in as an administrator to add, remove, and use this context menu.

    Special thank you to Matthew for creating and providing the downloadable .bat files in this tutorial.

    When you use the added New > Elevated Shortcut context menu, you will follow the same steps 5-7 below in option one here to have an elevated shortcut created for a specified app on your desktop to run the app as administrator (elevated) without getting a UAC prompt.

    5 Type the name (ex: "Elevated Command Prompt") you want used for the shortcut and task name, and press Enter. (see screenshot below)

    6 Type the full path of the application file without quotation marks (ex: "%windir%\System32\cmd.exe"), and press Enter.

    7 A shortcut will now be created on your desktop using the application's default icon with the name you provided in step 5. This will be your elevated shortcut.
    How to Add Create Elevated Shortcut to New Context Menu in Windows 10-elevated_shortcut_script.jpg


    EXAMPLE: Elevated Shortcut added to New context menu
    How to Add Create Elevated Shortcut to New Context Menu in Windows 10-new_elevated_shortcut_context_menu.png



    Here's How:

    1 Do step 2 (add) or step 3 (remove) below for what you would like to do.


    2 To Add "Elevated Shortcut" to New Context Menu

    A) Click/tap on the Download button below to download the file below, and go to step 4 below.

    Add_[Elevated_Shortcut]_into_context_menu.bat

    Download

    (Contents of .bat file for reference)
    Code:
    :: This script was created by Matthew Wai at TenForums.com/members/matthew-wai.html
    :: https://www.tenforums.com/tutorials/157437-how-add-create-elevated-shortcut-new-context-menu-windows-10-a.html
    :: ************************************************************************************/
    @echo off & Title Add [Elevated Shortcut] into the context menu & mode con cols=93 lines=14 & color 17
    (Net session >nul 2>&1)&&(cd /d "%~dp0")||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    :: ************************************************************************************/
    Set "[Item]=Elevated Shortcut" & Set "[Name]=Create_an_elevated_shortcut"
    Set "[Path]=%ProgramData%\TenForums.com\%[Name]%.cmd"
    If not exist "%ProgramData%\TenForums.com\" (MD "%ProgramData%\TenForums.com\")
    
    (REG ADD "HKCR\Elevated_lnk" /T REG_SZ /D "%[Item]%" /F)
    (REG ADD "HKCR\.lnk_elevated" /T REG_SZ /D "Elevated_lnk" /F)
    (REG ADD "HKCR\.lnk_elevated\ShellNew" /V "Command" /T REG_SZ /D "schtasks /run /tn ""Apps\%[Name]%""" /F)
    (REG ADD "HKCR\.lnk_elevated\ShellNew" /V "IconPath" /T REG_SZ /D "%WinDir%\System32\imageres.dll,73" /F)
    (REG ADD "HKCR\.lnk_elevated\ShellNew\Config" /V "BeforeSeparator" /F)
    Cls
    If errorlevel 1 (echo.
    echo ====================================================================
    echo.	
    echo          The script has failed to perform the operations.
    echo          Press any key to exit.
    echo.	        
    echo ====================================================================
    pause > nul & EXIT)
    echo.
    echo          The script is creating a new task with highest privileges.
    echo          Please wait for a while.
    echo.
    :: ************************************************************************************/
    IF exist "%[Path]%" (DEL "%[Path]%")
    (
    echo :: This script was created by Matthew Wai at TenForums.com/members/matthew-wai.html
    echo :: https://www.tenforums.com/tutorials/157437-how-add-create-elevated-shortcut-new-context-menu-windows-10-a.html 
    echo :: ************************************************************************************/
    echo @echo off ^& Title Create an elevated shortcut without a UAC prompt ^& mode con cols=90 lines=22 ^& color 17
    echo ^(Net session ^>nul 2^>^&1^)^&^&^(cd /d "%%~dp0"^)^|^|^(PowerShell start """%%~0""" -verb RunAs ^& Exit /B^) 
    echo :: ************************************************************************************/
    echo @ECHO OFF ^& setlocal
    echo echo. ^& echo.
    echo SET /P "[Name]= --> Please key in the name (without special characters) of the application you want to        run as an administrator (for example Elevated command prompt) and then press [Enter]:     "
    echo echo. ^& echo.
    echo Set "[M]=    Please do not leave a space before or after the file path."
    echo :Enter_the_path
    echo SET /P "[Path]= --> Please key in (or copy and paste) the full path (without quotation marks) of the          application file (for example %windir%\System32\cmd.exe) and then press [Enter]:        " 
    echo.
    echo Set "P=""%%[Path]%%"""
    echo Set "(P)=%%P: ""=""%%"
    echo Set "[P]=%%P:"" =""%%"
    echo If not "%%P%%"=="%%(P)%%" ^(Echo. ^& Echo %%[M]%% ^& Echo. ^& Goto Enter_the_path^)
    echo If not "%%P%%"=="%%[P]%%" ^(Echo. ^& Echo %%[M]%% ^& Echo. ^& Goto Enter_the_path^)
    echo echo.
    echo echo       The script is creating an elevated task with highest privileges.
    echo echo       Please wait for a while.
    echo echo.
    echo :: ************************************************************************************/
    echo For /f "tokens=*" %%%%I in ^('WhoAmI /user'^) Do ^(for %%%%A in ^(%%%%~I^) Do ^(set "[SID]=%%%%A"^)^)
    echo Set "[Task_name]=%%[Name]: =_%%"	
    echo IF EXIST "%%temp%%\%%[Task_name]%%.xml" ^(DEL "%%temp%%\%%[Task_name]%%.xml"^)	
    echo IF EXIST "%%temp%%\Task.vbs" ^(DEL "%%temp%%\Task.vbs"^)	
    echo.
    echo echo Set X=CreateObject^("Scripting.FileSystemObject"^) ^>^> "%%temp%%\Task.vbs"
    echo echo Set Z=X.CreateTextFile^("%%temp%%\%%[Task_name]%%.xml",True,True^)^>^> "%%temp%%\Task.vbs"
    echo Set "W=echo Z.writeline "	
    echo (
    echo %%W%%"<?xml version=""1.0"" encoding=""UTF-16""?>"
    echo %%W%%"<Task version=""1.4"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
    echo %%W%%"<RegistrationInfo>"
    echo %%W%%"<Author>%%username%%</Author>"
    echo %%W%%"<Description>To run the application/CMD script as an administrator with no UAC prompt.</Description>"
    echo %%W%%"</RegistrationInfo>"
    echo %%W%%"<Triggers />"
    echo %%W%%"<Principals>"
    echo %%W%%"<Principal id=""Author"">"
    echo %%W%%"<UserId>%%[SID]%%</UserId>"
    echo %%W%%"<LogonType>InteractiveToken</LogonType>"
    echo %%W%%"<RunLevel>HighestAvailable</RunLevel>"
    echo %%W%%"</Principal>"
    echo %%W%%"</Principals>"
    echo %%W%%"<Settings>"
    echo %%W%%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
    echo %%W%%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
    echo %%W%%"<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>"
    echo %%W%%"<AllowHardTerminate>true</AllowHardTerminate>"
    echo %%W%%"<StartWhenAvailable>false</StartWhenAvailable>"
    echo %%W%%"<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>"
    echo %%W%%"<IdleSettings>"
    echo %%W%%"<StopOnIdleEnd>true</StopOnIdleEnd>"
    echo %%W%%"<RestartOnIdle>false</RestartOnIdle>"
    echo %%W%%"</IdleSettings>"
    echo %%W%%"<AllowStartOnDemand>true</AllowStartOnDemand>"
    echo %%W%%"<Enabled>true</Enabled>"
    echo %%W%%"<Hidden>false</Hidden>"
    echo %%W%%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
    echo %%W%%"<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>"
    echo %%W%%"<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>"
    echo %%W%%"<WakeToRun>false</WakeToRun>"
    echo %%W%%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
    echo %%W%%"<Priority>7</Priority>"
    echo %%W%%"</Settings>"
    echo %%W%%"<Actions Context=""Author"">"
    echo %%W%%"<Exec>"
    echo %%W%%"<Command>cmd.exe</Command>"
    echo %%W%%"<Arguments>/c start ""%%[Name]%%"" " ^^^& """%%[Path]%%""" ^^^& "</Arguments>"
    echo %%W%%"</Exec>"
    echo %%W%%"</Actions>"
    echo %%W%%"</Task>"
    echo ^)^>^> "%%temp%%\Task.vbs"
    echo echo Z.Close ^>^> "%%temp%%\Task.vbs"
    echo "%%temp%%\Task.vbs"
    echo Del "%%temp%%\Task.vbs"	
    echo schtasks /create /xml "%%temp%%\%%[Task_name]%%.xml" /tn "Apps\%%[Task_name]%%"
    echo If errorlevel 1 ^(DEL "%%temp%%\%%[Task_name]%%.xml" ^& echo.
    echo echo  =======================================================================================
    echo echo     The script has failed to create the task. You may have entered a name already 
    echo echo     used in Task Scheduler or a name containing special characters/punctuation marks.
    echo echo     Otherwise, you may have entered a file path that contains special characters or 
    echo echo     punctuation marks. Please re-run the script and enter a different/valid name/file
    echo echo     path. Press any key to close this message. 
    echo echo  =======================================================================================
    echo pause ^> nul ^& Exit^) else ^(DEL "%%temp%%\%%[Task_name]%%.xml"^)
    echo. 
    echo IF EXIST "%%temp%%\Shortcut.vbs" ^(DEL "%%temp%%\Shortcut.vbs"^)	
    echo (echo Set A = CreateObject^^^("WScript.Shell"^^^) ^& echo Desktop = A.SpecialFolders^^^("Desktop"^^^) ^& echo Set B = A.CreateShortcut^^^(Desktop ^^^& "\%%[Name]%%.lnk"^^^) ^& echo B.IconLocation = "%%[Path]%%" ^& echo B.TargetPath = "%%windir%%\System32\schtasks.exe" ^& echo B.Arguments = "/run /tn ""Apps\%%[Task_name]%%""" ^& echo B.Save ^& echo WScript.Quit^)^> "%%temp%%\Shortcut.vbs"
    echo "%%temp%%\Shortcut.vbs"	
    echo.
    echo If errorlevel 1 ^(Del "%%temp%%\Shortcut.vbs" ^& echo.
    echo echo  ====================================================================================
    echo echo      The script has failed to complete the operation.
    echo echo      Please press any key to close this message.
    echo echo  ====================================================================================
    echo pause ^> nul ^& Exit^) else ^(Del "%%temp%%\Shortcut.vbs" ^& echo.
    echo echo  ====================================================================================
    echo echo      The shortcut "%%[Name]%%" has been created on the desktop.
    echo echo      You may double-click on it to run the application.
    echo echo      Please press any key to close this message.
    echo echo  ====================================================================================
    echo pause ^> nul ^& Exit^)
    )> "%[Path]%"
    
    :: ************************************************************************************/
    For /f "tokens=*" %%I in ('WhoAmI /user') Do (for %%A in (%%~I) Do (set "[SID]=%%A"))
    IF EXIST "%temp%\%[Name]%.xml" (DEL "%temp%\%[Name]%.xml")	
    IF EXIST "%temp%\Task.vbs" (DEL "%temp%\Task.vbs")	
    
    echo Set X=CreateObject("Scripting.FileSystemObject") >> "%temp%\Task.vbs"
    echo Set Z=X.CreateTextFile("%temp%\%[Name]%.xml",True,True)>> "%temp%\Task.vbs"
    Set "W=echo Z.writeline "	
    (	
    %W%"<?xml version=""1.0"" encoding=""UTF-16""?>"
    %W%"<Task version=""1.4"" xmlns=""http://schemas.microsoft.com/windows/2004/02/mit/task"">"
    %W%"<RegistrationInfo>"
    %W%"<Author>Matthew Wai</Author>"
    %W%"<Description>To run the application/CMD script as an administrator with no UAC prompt.</Description>"
    %W%"</RegistrationInfo>"
    %W%"<Triggers />"
    %W%"<Principals>"
    %W%"<Principal id=""Author"">"
    %W%"<UserId>%[SID]%</UserId>"
    %W%"<LogonType>InteractiveToken</LogonType>"
    %W%"<RunLevel>HighestAvailable</RunLevel>"
    %W%"</Principal>"
    %W%"</Principals>"
    %W%"<Settings>"
    %W%"<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>"
    %W%"<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"
    %W%"<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>"
    %W%"<AllowHardTerminate>true</AllowHardTerminate>"
    %W%"<StartWhenAvailable>false</StartWhenAvailable>"
    %W%"<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>"
    %W%"<IdleSettings>"
    %W%"<StopOnIdleEnd>true</StopOnIdleEnd>"
    %W%"<RestartOnIdle>false</RestartOnIdle>"
    %W%"</IdleSettings>"
    %W%"<AllowStartOnDemand>true</AllowStartOnDemand>"
    %W%"<Enabled>true</Enabled>"
    %W%"<Hidden>false</Hidden>"
    %W%"<RunOnlyIfIdle>false</RunOnlyIfIdle>"
    %W%"<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>"
    %W%"<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>"
    %W%"<WakeToRun>false</WakeToRun>"
    %W%"<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>"
    %W%"<Priority>7</Priority>"
    %W%"</Settings>"
    %W%"<Actions Context=""Author"">"
    %W%"<Exec>"
    %W%"<Command>""%[Path]%""</Command>"
    %W%"</Exec>"
    %W%"</Actions>"
    %W%"</Task>"
    )>> "%temp%\Task.vbs"	
    echo Z.Close >> "%temp%\Task.vbs"	
    "%temp%\Task.vbs"	
    Del "%temp%\Task.vbs"	
    schtasks /create /xml "%temp%\%[Name]%.xml" /tn "Apps\%[Name]%"
    
    If %errorlevel%==1 (DEL "%temp%\%[Name]%.xml" & echo.
    echo     ====================================================================================
    echo          The script has failed to create the task "%[Name]%".
    echo          The task might already exist in "Task Scheduler Library"--^>"Apps". 
    echo          Press any key to close this message. 
    echo     ====================================================================================
    pause > nul & Exit) else (DEL "%temp%\%[Name]%.xml"
    echo     ====================================================================================
    echo          The item "Elevated Shortcut" has been added into the context menu.
    echo          The item will appear when you hover the cursor over the item "New".
    echo          All the scheduled tasks will be in "Task Scheduler Library"--^>"Apps".
    echo          You may edit/disable/delete the tasks if need be.
    echo          Please press any key to close this message.
    echo     ====================================================================================
    pause > nul & Exit)


    3 To Remove "Elevated Shortcut" from New Context Menu

    This is the default setting.

    A) Click/tap on the Download button below to download the file below, and go to step 4 below.

    Remove_Elevated_Shortcut_from_New_context_menu.bat

    Download

    (Contents of .bat file for reference)
    Code:
    :: This script was created by Matthew Wai on TenForums at https://www.tenforums.com
    :: https://www.tenforums.com/tutorials/16236-add-create-restore-point-context-menu-windows-10-a.html
    :: ************************************************************************************/
    @echo off & mode con cols=88 lines=8 & color 17
    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    :: ************************************************************************************/
    cd /d "%~dp0"
    Reg delete "HKCR\Elevated_lnk" /f
    Reg delete "HKCR\.lnk_elevated" /f
    Schtasks /delete /tn "Apps\Create_an_elevated_shortcut" /f
    Del "%ProgramData%\TenForums.com\Create_an_elevated_shortcut.cmd"
    RmDir "%ProgramData%\TenForums.com\"
    
    Echo     The item [Elevated Shortcut] has been removed from the context menu.
    Echo     Please press a key to close this message.
    Pause>nul
    Exit


    4 Save the .bat file to your desktop.

    5 Double click/tap on the downloaded .reg file to unblock and run it.

    6 When the .bat file script has finished adding or removing the "Elevated Shortcut" context menu item, press any key to close the command prompt. (see screenshots below)

    How to Add Create Elevated Shortcut to New Context Menu in Windows 10-add_elevated_shortcut_to_new_context_menu.png How to Add Create Elevated Shortcut to New Context Menu in Windows 10-remove_elevated_shortcut_from_new_context_menu.png

    7 You can now delete the downloaded .bat file if you like.


    That's it,
    Shawn






  1. Posts : 7,606
    Windows 10 Home 20H2
       #1

    Add_[Elevated_Shortcut]_into_context_menu.bat

    @Brink, can you upload the above version, which has been updated as per the modified script in the following post?

    Create Elevated Shortcut without UAC prompt in Windows 10
      My Computer


  2. Posts : 68,881
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #2

    Matthew Wai said:
    Add_[Elevated_Shortcut]_into_context_menu.bat

    @Brink, can you upload the above version, which has been updated as per the modified script in the following post?

    Create Elevated Shortcut without UAC prompt in Windows 10
    Thank you Matthew. Now updated.
      My Computers


 

Tutorial Categories

How to Add Create Elevated Shortcut to New Context Menu in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 06:59.
Find Us




Windows 10 Forums