[wpkg-users] Old Feature Request / Perhaps New Idea
Pendl Stefan
stefan.pendl at haidlmair.at
Wed Feb 17 15:35:56 CET 2010
>
> > On the other hand you can create JS scripts to create shortcuts, see
> > http://wpkg.org/Category:Utility_Scripts for an example of such a
> > script for desktop shortcuts.
>
> Well - this won't help if you want to delete shortcuts, or move them around, or do something in the global appdata (which is different on XP from 7).
>
> Most Installers already create shortcuts - but often too many or in wrong/unwanted places. Or place stuff in the Startup-Folder.
>
The function WshShell.SpecialFolders() does get the paths for the special folders know to the system, so this will always return the correct folder for any Windows version starting with Win95.
To delete shortcuts, I use the following additional script:
# --- code start (watch for line wraps)
/*
Script to delete a desktop shortcut
Usage:
DeleteShortCut.js {options}
Options:
/name:"name of the shortcut to delete" ... required
*/
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 LinkPath = null;
if ( argsNamed.Exists("name") ) {
LinkName = argsNamed.Item("name");
if ( LinkName == null ) {
WScript.StdErr.WriteLine("Name missing /name:\"{name}\" - exiting ...");
WScript.Quit(4);
}
} else {
WScript.StdErr.WriteLine("Option /name:\"{name}\" missing - exiting ...");
WScript.Quit(3);
}
LinkPath = strDesktop + "\\" + LinkName + ".lnk"
try {
FSobj.DeleteFile(LinkPath)
} catch(e) {}
WScript.Quit(0);
# --- code end
In addition reading the registry is a bit risky, since there are two locations where those special folders are stored and one of them is only used for backwards compatibility with Win9x/ME.
You may check http://msdn.microsoft.com/en-us/library/0ea7b5xe%28VS.85%29.aspx for a full list of supported special folders, to have a workaround till this might get implemented.
---
Stefan
More information about the wpkg-users
mailing list