20090316

creating shortcuts from WSH with javascript

made a little function in jscript (run with wsh or csh cscript wscript) to create windows shortcuts automatically to the desktop,...


might still be a bug in it for targetpath, but it works kinda good already ;)

//createShortCut ("shortcutname","c:\windows\notepad.exe","c:\temp\somefile.txt","c:\temp")

function createShortCut(name , target, args, wdir) {

var shell = WScript.CreateObject("WScript.Shell");

var dpath = shell.SpecialFolders("Desktop");

var short = shell.CreateShortcut(dpath + "\\" + name + ".lnk");

short.TargetPath = '"'+target+'" '+args;

short.WorkingDirectory = wdir;

short.WindowStyle = 0;

short.IconLocation = target+",0";

return(short.Save());

}



                     The following special folders are available:

  • AllUsersDesktop

  • AllUsersStartMenu

  • AllUsersPrograms

  • AllUsersStartup

  • Desktop

  • Favorites

  • Fonts

  • MyDocuments

  • NetHood

  • PrintHood

  • Programs

  • Recent

  • SendTo

  • StartMenu

  • Startup

  • Templates

                     

--
map{ map{tr|10|# |;print} split//,sprintf"%.8b\n",$_}
unpack'C*',unpack'u*',"5`#8<3'X`'#8^-@`<-CPP`#8V/C8`"

No comments:

Post a Comment