Friday, August 7, 2009

cmd create a .lnk(shortcut)

We don't use any extra command tool that you have to download somewhere
else and worry about its security, but the winxp built-in cscript(or
wscript, if you prefer) to excute a little Jscript creat-a-lnk.js(source
followed), and create your shortcut on the desktop(or anywhere you want
to), quick and safe!

--------------------create-a-lnk.js--------------------
Shell = new ActiveXObject("WScript.Shell");
DesktopPath = Shell.SpecialFolders("Desktop");
link = Shell.CreateShortcut(DesktopPath + "\\shortcut-name.lnk");
// If you want:
// link = Shell.CreateShortcut("D:\\path\\to\\your\\shortcut-name.lnk");
link.Description = "a lnk created from cmd";
link.HotKey = "CTRL+ALT+SHIFT+l";
//link.IconLocation = ".exe,1";
link.TargetPath = Shell.CurrentDirectory + "\\lnk-to-this.txt";
// If you want:
// link.TargetPath = "E:\\path\\to\\your\\target.exe";
link.WindowStyle = 3;
link.Save();
--------------------create-a-lnk.js--------------------

Personally, I feel this is much better than running some unkown
XcreateLnk.exe as you can see the source, learn the process, and
guarante the security of your system.

No comments: