Reputation: 283
How can I create a shortcut for a folder by using windows command line
Upvotes: 4
Views: 12751
Reputation: 18827
Give a try for this example to run it with administrator privileges :
@echo off
cls & color 0A & echo.
Mode con cols=60 lines=5
Title Create a shortcut by using windows command line
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
CLS
Echo.
Echo.
ECHO **************************************
ECHO Running Admin shell... Please wait...
ECHO **************************************
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
Echo.
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************
setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
(
ECHO Set UAC = CreateObject^("Shell.Application"^)
ECHO args = "ELEV "
ECHO For Each strArg in WScript.Arguments
ECHO args = args ^& strArg ^& " "
ECHO Next
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1
)> "%temp%\OEgetPrivileges.vbs"
"%SystemRoot%\System32\WScript.exe" "%temp%\OEgetPrivileges.vbs" %*
exit /B
:gotPrivileges
if '%1'=='ELEV' shift /1
setlocal & pushd .
cd /d "%~dp0"
::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
cls
mklink /d sysfolder "%windir%\system32\"
Pause
Upvotes: 0
Reputation: 11
just use:
mklink <saveShortcutAs> <targetOfShortcut>
and you can find more options here: https://technet.microsoft.com/en-us/library/cc753194.aspx
Upvotes: 1