OS: Windows 7
I am trying to create a link to the desktop folder via batch like this:
mklink "%userprofile%\Desktop\MyExe" "%~dp0\MyExe.exe"
The command worked, but how to indicate MyExe.exe
execute at "%~dp0"
?
MyExe.exe
looks like run at the current folder, so it can't load my config file.
Update:
Got the different problem by using VBS, run code in below will create a shortcut
for C:\Users\jiu\Desktop\MyExe.exe
, But I want MyExe.exe
.
Set oWS = WScript.CreateObject("WScript.Shell")
userProfilePath = oWS.ExpandEnvironmentStrings("%UserProfile%")
currParentFolder = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
linkPath = userProfilePath + "\Desktop\MyExe.LNK"
Set oLink = oWS.CreateShortcut(linkPath)
oLink.TargetPath = "MyExe.exe"
oLink.WorkingDirectory = currParentFolder
oLink.Save
Based upon the information you have provided, here's a strange looking batch file which should create your desktop shortcut for you:
;@Rundll32 AdvPack.dll,LaunchINFSection "%~0",,1
;@GoTo :EOF
[Version]
Signature="$Windows NT$"
[DefaultInstall]
ProfileItems=AddLnk
[AddLnk]
Name="MyExe",8,16
CmdLine=1,,"MyExe.exe"
InfoTip="Execute MyExe.exe"
WorkingDir=1
You can optionally modify:
8
.9
.10
.