Skip to content

Instantly share code, notes, and snippets.

@hexandcube
Created March 26, 2023 09:41
Show Gist options
  • Save hexandcube/5ebccaad175a5b1a2f8ab76fb9ccf5c0 to your computer and use it in GitHub Desktop.
Save hexandcube/5ebccaad175a5b1a2f8ab76fb9ccf5c0 to your computer and use it in GitHub Desktop.
This PC Shortcut Creator
@echo off
cls
title Create shortcut in This PC
if exist %1 goto setParameterToVariable
echo Drop your file/folder you want to create a shortcut for here (or enter the file/folder path).
set/p filePath=">"
goto setShortcutName
:setParameterToVariable
set filePath=%1
:setShortcutName
set filePath=%filePath:"=%
set/p name="Name for your shortcut: "
echo.
echo Creating shortcut...
echo Set oWS = WScript.CreateObject("WScript.Shell") > CreateShortcut.vbs
echo sLinkFile = "%appdata%/Microsoft/Windows/Network Shortcuts/%name%.lnk" >> CreateShortcut.vbs
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> CreateShortcut.vbs
echo oLink.TargetPath = "%filePath%" >> CreateShortcut.vbs
echo oLink.Save >> CreateShortcut.vbs
cscript CreateShortcut.vbs >nul
del CreateShortcut.vbs
echo Shortcut Created!
pause >nul
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment