The following code works fine on my Windows 2000 box and my Win NT box, but fails with the error in the title when executed on a Citrix XP box with a Win2000 backbone. Suggestions?
The code finds shortcuts on the desktop (actually, in whatever folder is passed to the procedure as sFolder), and searches for one string/replaces with another (sOldstring and sNewString). Not too exciting.
Dim sExeFile As String
Set oShell = CreateObject("WScript.Shell")
Set ofso = CreateObject("Scripting.FilesystemObject")
Set ofolder = ofso.GetFolder(sFolder)
Set oFiles = ofolder.Files
For Each ofile In oFiles
If LCase(ofso.GetExtensionName(ofile)) = "lnk" Then
Set f = ofso.getfile(ofile)
' This just makes any "read only" shortcuts not read only anymore. I don't bother changing them back.
If f.Attributes And 1 Then
f.Attributes = f.Attributes - 1
Set olnk = oShell.CreateShortcut(ofile)
sExeFile = LCase(olnk.targetpath)
sExeFile = Replace(sExeFile, sOldString, sNewString)
olnk.targetpath = sExeFile
sWorkDir = LCase(olnk.workingdirectory)
sWorkDir = Replace(sWorkDir, sOldString, sNewString)
olnk.workingdirectory = sWorkDir