Skip to content

Instantly share code, notes, and snippets.

@Fastjur
Created August 21, 2017 19:07
Show Gist options
  • Save Fastjur/a2baa206047ea9e2846d4bc1914d8b77 to your computer and use it in GitHub Desktop.
Save Fastjur/a2baa206047ea9e2846d4bc1914d8b77 to your computer and use it in GitHub Desktop.
Create a shortcut to a program in your Start Menu using the context menu 'Send to' function.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Creates a shortcut to the selected file in
:: the start menu of the current user.
:: INSTALLATION:
:: 1. Open 'run', type in 'shell:sendto' and press enter
:: 2. Put this batch file in the folder that just opened
:: 3. A new 'Start Menu.bat' entry should now appear in your
:: context menu 'Send to' section.
:: Thanks to: https://stackoverflow.com/a/9253018
:: https://superuser.com/a/455383
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
set filepath=%1
for %%A in (%filepath%) do (
set name=%%~nA
)
echo echo Adding link to %filepath% to Start Menu (%name%)
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\Start Menu\Programs\%name%.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%1" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment