' ' $Id: //websites/unixwiz/unixwiz.net/webroot/evo/evo-fixlinks.vbs#2 $ ' ' written by : Stephen J. Friedl ' Software Consultant ' Tustin, California USA ' http://www.unixwiz.net/evo/ ' ' This program is used to repair desktop links to the various tools ' found in the RD directory: mainly eBackup.exe and SetAdminRights. ' These are normally shortcuts on the desktop, but as new versions ' of Evo are activated, they sometimes get moved around to a new ' directory. ' ' Example: RegistrationDaemonService00000001 is the first directory ' created by Evo when it installs the RD service, but unless that ' service is stopped before activating a new version, it won't ' be able to completely remove it, so creates a new dir: ' ' RegistrationDaemonService00000002 ' ' The original directory won't have the EXEs, so the desktop links ' are broken. Ugh. ' ' This program runs through the DeploymentService directory and ' looks for any subdirs of the form RegistrationDaemonService######## ' and looks for EBackup or SetAdminRights that live there. ' ' NOTE: we could get the path to the RD directly from the Services ' database, but these paths are built with short ~ names and are ' just too ugly: ' ' C:\PROGRA~1\EVOLUT~1\DEPLOY~1\RegistrationDaemonService00000001 ' ' TODO ' ---- ' Learn VBScript better so we can put the tools we need in some kind of ' object or hash ' directory where the DeploymentService is installed DSdir = "C:\Program Files\Evolution\DeploymentService" version = "Unixwiz.net evo-fixlinks - 1.0.0 - 2008/03/23" & chr(13) & chr(13) link_eBackup = "eBackup.lnk" link_SAR = "Set Admin Rights.lnk" dir_eBackup = "" dir_SAR = "" path_eBackup = "" path_SAR = "" ' create a regex object that we use to match the folder names ' found in the DeploymentService directory. We're fussy that ' it *exactly* and *only* match these names and not any other ' forms, such as those with "OLD" in the name. set objRE = New RegExp objRE.Pattern = "^RegistrationDaemonService[0-9]{8}$" objRE.IgnoreCase = false '------------------------------------------------------------------------ ' Create a Filesystem object and enumerate all the subfolders of the ' Deployment Service directory. For each one, see if the folder name ' matches our pattern (ignoring the Package Server or other services), ' then see if there is an EBackup or SetAdminRights there. Save the ' paths if found in any given loop. set objFSO = CreateObject("Scripting.FileSystemObject") RDdir = "" For each objSubFolder in objFSO.GetFolder(DSdir).Subfolders if objRE.test(objSubfolder.name) then fullpath = DSdir & "\" & objSubfolder.name ' look for eBackup.exe tmp_ebackuppath = fullpath & "\EBackup.exe" if objFSO.FileExists(tmp_ebackuppath) then path_eBackup = tmp_ebackuppath dir_eBackup = fullpath end if ' look for SetAdminRights.exe tmp_SARpath = fullpath & "\SetAdminRights.exe" if objFSO.FileExists(tmp_SARpath) then path_SAR = tmp_SARpath dir_SAR = fullpath end if end if next '------------------------------------------------------------------------ ' If we don't find *both* of them, something is wrong and we need to ' tell the user: no link updates ' missing = "" if len(path_eBackup) = 0 then missing = missing & " eBackup" end if if len(path_SAR) = 0 then missing = missing & " SetAdminRights" end if if len(missing) > 0 then wscript.echo version & _ "ERROR: cannot find all tools (missing: " & missing & ")" & _ chr(13) & _ "No shortcuts updated" wscript.quit end if '------------------------------------------------------------------------ ' Determine the path of the desktop so we know where to put our shortcuts ' We make it a point to only work with the *current* user's desktop ' and not the All Users desktop. ' ' Note that because of the prior code, we are sure we have *both* ' paths. ' set oWS = WScript.CreateObject("WScript.Shell") desktopDir = oWS.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop" set objDesktop = objFSO.GetFolder(desktopDir) link_eBackup = desktopDir & "\" & link_eBackup link_SAR = desktopDir & "\" & link_SAR set oLink = oWS.CreateShortcut(link_eBackup) oLink.TargetPath = path_eBackup oLink.Arguments = "" oLink.Description = "eBackup" oLink.WindowStyle = 1 oLink.WorkingDirectory = dir_eBackup oLink.IconLocation = path_eBackup & ", 0" oLink.HotKey = "" oLink.Save set oLink = oWS.CreateShortcut(link_SAR) oLink.TargetPath = path_SAR oLink.Arguments = "" oLink.Description = "Set Admin Rights" oLink.WindowStyle = 1 oLink.WorkingDirectory = dir_SAR oLink.IconLocation = path_SAR & ", 0" oLink.HotKey = "" oLink.Save ' done! yay! wscript.echo version & "Desktop shortcuts to Evo tools updated successfully."