Reputation: 8120
The problem here is that, after creating a symlink to a batch file, the link does not run the batch file. Example:
mklink x x.cmd
When clicking on x
it opens x.cmd
in Notepad! Ordinary shortcuts (.lnk-files) work as expected.
> ftype cmdfile
cmdfile="%1" %*
> assoc .cmd
.cmd=cmdfile
So each .cmd-file should run itself.
Is there a solution?
Upvotes: 1
Views: 2629
Reputation: 53
One way would be to make hard links (mklink /H). But since I think you just need some kind of shortcut, try this:
1) Make a shell script *.vbs like this (shortcut_helper.vbs):
set WshShell = WScript.CreateObject("WScript.Shell" )
set oShellLink = WshShell.CreateShortcut(Wscript.Arguments.Named("shortcut") & ".lnk")
oShellLink.TargetPath = Wscript.Arguments.Named("target")
oShellLink.Arguments = Wscript.Arguments.Named("arg")
oShellLink.WindowStyle = 1
oShellLink.Save
2) Make your batch script start it like this from an batch file:
path_to_vbs\shortcut_helper /target:"file_path\file.bat" /shortcut:"shortcut_name" /arg:"optional_arguments"
Now 2) creates shortcuts (*.lnk) for you and you can then move them anywhere you like =)
Be careful though, *.vbs files MAY need admin rights in some circumstances.
Upvotes: 3