1
votes

How do i make a folder shortcut wiht Batch Commando Prompt?

i have tried this:

copy "C:\Windows" "C:\Users\%username%\Desktop\Windows.ink"

mklink "C:\Windows" "C:\Users\%username%\Desktop"

1
possible duplicate of creating a shortcut for a exe from a batch file - creating one for a folder is the same as creating one for an executable.Ken White

1 Answers

0
votes
@echo off
    call :createDesktopShortcut "%~1" "%~2"
    exit /b

:createDesktopShortcut targetOfShortcut nameOfShortcut
    if not exist "%~f1" goto :eof
    setlocal & set "tempFile=%temp%\%~nx0.vbs.tmp" & set "name=%~2" & if not defined name set "name=%~n1"
    echo(Set S=WScript.CreateObject("Wscript.Shell"):With S.Createshortcut(S.SpecialFolders("Desktop")+"\%~2.lnk"):.TargetPath="%~f1":.Save:End With>"%tempFile%"
    cscript //nologo //e:vbscript "%tempFile%">nul & del /f /q "%tempFile%" >nul 2>nul
    endlocal & goto :eof

Save as createDesktopShortcut.cmd and call it as

createDesktopShortcut.cmd "%windir%" "Win directory"