Changes

Create Desktop Icon

432 bytes added, 16:08, 24 April 2014
Added saveto parameter for saving shortcut in other than the default directory
<upgrade cmd='%ComSpec% /c if %PROCESSOR_ARCHITECTURE% == x86 cscript.exe "%WPKG_ROOT%\tools\CreateShortCut.js" /target:"%ProgramFiles%\RTM592\help" /name:"RTM v5.92 Hilfe" /icon:"%SystemRoot%\system32\shell32.dll, 23"' />
<upgrade cmd='%ComSpec% /c if %PROCESSOR_ARCHITECTURE% == AMD64 cscript.exe "%WPKG_ROOT%\tools\CreateShortCut.js" /target:"%ProgramFiles(x86)%\RTM592\help" /name:"RTM v5.92 Hilfe" /icon:"%SystemRoot%\system32\shell32.dll, 23"' />
 
 
<remove cmd='%ComSpec% /c if exist "%ALLUSERSPROFILE%\Desktop\RTM v5.92 Hilfe.lnk" del /f /q "%ALLUSERSPROFILE%\Desktop\RTM v5.92 Hilfe.lnk"' />
/*
Script to create a desktop shortcut
Usage:
CreateShortCut.js {options}
Options:
/name:"name of the shortcut to create" ... required
OR /icon:"fully qualified path to the icon resource, zero-based icon index"
/descr:"description of the shortcut" ... optional
/saveto:"saveto path specifies where shortcut is to be saved" ... optional, default: AllUsersDestop
*/
var argsNamed = WScript.Arguments.Named;
var argsUnnamed = WScript.Arguments.Unnamed;
var WshShell = WScript.CreateObject("WScript.Shell");
var FSobj = WScript.CreateObject("Scripting.FileSystemObject");
var strDesktop = WshShell.SpecialFolders("AllUsersDesktop");
var LinkName = null;
var LinkTarget = null;
var LinkIcon = null;
var LinkDescr = null;
var LinkSaveto = null;
if ( argsNamed.Exists("name") ) {
LinkName = argsNamed.Item("name");
if ( LinkName == null ) {
WScript.StdErr.WriteLine("Name missing /name:\"{name}\" - exiting ...");
WScript.Quit(3);
}
if ( argsNamed.Exists("target") ) {
LinkTarget = argsNamed.Item("target");
if ( LinkTarget == null ) {
WScript.StdErr.WriteLine("Target path missing /target:\"{target path}\" - exiting ...");
WScript.Quit(1);
}
if ( argsNamed.Exists("workdir") ) {
LinkWorkDir = argsNamed.Item("workdir");
if ( LinkWorkDir == null ) {
WScript.StdErr.WriteLine("Working directory path missing /workdir:\"{folder path}\" - exiting ...");
if ( FSobj.FileExists(LinkTarget) ) LinkWorkDir = FSobj.GetParentFolderName(LinkTarget);
}
if ( argsNamed.Exists("args") ) {
LinkArgs = argsNamed.Item("args");
if ( LinkArgs == null ) {
WScript.StdErr.WriteLine("Arguments missing /args:\"{arguments}\" - exiting ...");
}
}
if ( argsNamed.Exists("icon") ) {
LinkIcon = argsNamed.Item("icon");
if ( LinkIcon == null ) {
WScript.StdErr.WriteLine("Icon location missing /icon:\"{full path to icon resource}[, {index}]\" - exiting ...");
}
}
if ( argsNamed.Exists("descr") ) {
LinkDescr = argsNamed.Item("descr");
if ( LinkDescr == null ) {
WScript.StdErr.WriteLine("Description missing /descr:\"{description}\" - exiting ...");
}
var oShellLink if ( argsNamed.Exists("saveto") ) { LinkSaveto = WshShellargsNamed.CreateShortcutItem(strDesktop + "saveto"); if ( LinkSaveto == null ) { WScript.StdErr.WriteLine("Saveto path missing /saveto:\"{saveto}\" + LinkName +"- exiting ...lnk"); WScript.Quit(9); }} else { LinkSaveto = strDesktop}
var oShellLink = WshShell.CreateShortcut(FSobj.BuildPath(LinkSaveto, LinkName + ".lnk"));
oShellLink.TargetPath = LinkTarget;
if ( LinkWorkDir != null ) oShellLink.WorkingDirectory = LinkWorkDir;
if ( LinkIcon != null ) oShellLink.IconLocation = LinkIcon;
if ( LinkDescr != null ) oShellLink.Description = LinkDescr;
oShellLink.Save();
WScript.Quit(0);
</source>