Create Shortcuts From Command-Line

J

Joe Caverly

Hi,
CmdUtils from http://www.maddogsw.com/cmdutils has a command-line
utility called ContextMenu, "which displays the shell context menu for
the specified file(s); from here, with one more step, you can get
Properties, Quick View, or any other supported action for the
specified file(s)", including the ability to create a shortcut.

Other utilities include Recycle, PropsFor, Bin, FixP, and the full
source code for all of these utilities.

Joe
 
L

Laurent Herve

Joe Caverly said:
Hi,
CmdUtils from http://www.maddogsw.com/cmdutils has a command-line
utility called ContextMenu, "which displays the shell context menu for
the specified file(s); from here, with one more step, you can get
Properties, Quick View, or any other supported action for the
specified file(s)", including the ability to create a shortcut.

Other utilities include Recycle, PropsFor, Bin, FixP, and the full
source code for all of these utilities.

Joe

Nice idea since it is impossible to created shortcuts from commun DOS
prompt,
-and i just see that the shortcuts have the same name as the original the
file ! that
is very nice, i have posted on msdos.batch few months agoo, there was no
solution !
Thanks a lot,

laurent
 
T

Toad

Laurent said:
Nice idea since it is impossible to created shortcuts from commun DOS
prompt,
-and i just see that the shortcuts have the same name as the original
the file ! that
is very nice, i have posted on msdos.batch few months agoo, there was
no solution !
Thanks a lot,

laurent

Not impossible at all. Windows comes with something called WSH (Windows
Scriptng Host) which allows for scripting lots of things. One thing
that can be scripted is the creation of shortcuts. A script can be run
from the command line.

Here is an example taken right from the WSH doc using Java Script (VB
Script works too):

DesktopPath = Shell.SpecialFolders("Desktop");
link = Shell.CreateShortcut(DesktopPath + "\\test.lnk");
link.Arguments = "1 2 3";
link.Description = "test shortcut";
link.HotKey = "CTRL+ALT+SHIFT+X";
link.IconLocation = "foo.exe,1";
link.TargetPath = "c:\\blah\\foo.exe";
link.WindowStyle = 3;
link.WorkingDirectory = "c:\\blah";
link.Save();

Save this in a .JS file on disk and simple run it from the command
line, changing the various paths to be what you want.

WSH makes batch files pretty useless except for launching scripts.

Also, I recommend running cscript.exe //H:cscript from the command line
to set the default scripting engine to the command line version.

Toad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top