vbscript to clean shortcuts?

Soldato
Joined
26 Feb 2009
Posts
14,817
Location
Exeter
Currently moving our Citrix users from 2003 x86 to 2008 x64 and am using redirection of the desktop folder to ensure shotcuts to files and files on the desktop are maintained.

Unfortunately, a lot of users also have program shortcuts on their desktop, which used to point to C:\program files\ but now the programs will reside in C:\program files (x86)\....

So looking for a script to sort them out when the users logs in, either by deleting all shortcuts that point to C:\program files\ on first login, or fixing the broken ones.... any ideas?
 
try this, i think this works, tried a couple of time.

It looks for every shortcut "lnk" on the desktop and if that shortcut is linked to "program files" then it changes it to "program files (x86)" so should be failsafe.
Code:
'On Error Resume Next
  Dim fso, folder, files, oWSsFolder, WshShell 
 
Set fso = CreateObject("Scripting.FileSystemObject")
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oWS = WScript.CreateObject("WScript.Shell")
Set folder = fso.GetFolder(strDesktop)
Set files = folder.Files
 
  For each folderIdx In files

if right(folderIdx.Name,3)="lnk" then


sLinkFile = folderIdx.path
Set oLink = oWS.CreateShortcut(sLinkFile)

if instr(lcase(oLink.TargetPath),"program files")>0 then
    'msgbox (folderIdx.Name)
oLink.TargetPath=replace(lcase(oLink.TargetPath),"program files","program files (x86)")
'msgbox "TP" & oLink.TargetPath
oLink.Save
end if
end if
  Next
 
Last edited:
Excellent - 2 good options.

The only problem with just adding x86 onto the path is Internet Explorer shortcuts...

If i delete their shortcuts, some people would think all their files have gone!
 
Excellent - 2 good options.

The only problem with just adding x86 onto the path is Internet Explorer shortcuts...

If i delete their shortcuts, some people would think all their files have gone!

??

Don't get you, you are not deleting them just renaming the shortcut target path, IE would be in program files (x86) also no?
 
Back
Top Bottom