Metronome09
asked on
Deleting Shortcuts in Windows Vista using VBScript
I am looking to automatically delete a shortcut that is created in Windows Vista when we install a program via MSI. The following code works perfectly in Windows XP, however errors out in Vista.
For Vista, the equivalent variable should be:
strShortcut = "C:\Users\Public\Public Desktop\FILENAME.lnk"
Ideally, I would like to use one script to handle both XP and Vista without prompting users or alerting them of its presence.
Offering more points for faster resolution as I need this solved as quickly as is humanly possible.
Thanks.
For Vista, the equivalent variable should be:
strShortcut = "C:\Users\Public\Public Desktop\FILENAME.lnk"
Ideally, I would like to use one script to handle both XP and Vista without prompting users or alerting them of its presence.
Offering more points for faster resolution as I need this solved as quickly as is humanly possible.
Thanks.
Set objFSO = CreateObject("Scripting.FileSystemObject")
strShortcut = "C:\Documents and Settings\All Users\Desktop\FILENAME.lnk"
If objFSO.FileExists(strShortcut) Then
objFSO.DeleteFile(strShortcut)
End If
ASKER
Upped points to 500 for the solution and/or suggestions that lead me to the solution.
@Dinomix--This solution must work in Vista and I would much prefer to handle it via VBScripts as that is the standard method for everything else that we deploy.
Below is the full script that I have so far:
@Dinomix--This solution must work in Vista and I would much prefer to handle it via VBScripts as that is the standard method for everything else that we deploy.
Below is the full script that I have so far:
Set objFSO = CreateObject("Scripting.FileSystemObject")
strShortcut = "C:\Documents and Settings\All Users\Desktop\FILENAME.lnk"
strVistaShortcut = "C:\Users\Public\Public Desktop\FILENAME.lnk"
If objFSO.FileExists(strShortcut) Then
objFSO.DeleteFile(strShortcut)
End If
If objFSO.FileExists(strVistaShortcut) Then
objFSO.DeleteFile(strVistaShortcut)
End If
Set objShell = CreateObject("WScript.Shell")
Set objFSO2 = CreateObject("Scripting.FileSystemObject")
strDesktop = objShell.SpecialFolders("Desktop")
If objFSO2.FileExists(strDesktop & "FILENAME.lnk") Then
objFSO2.DeleteFile(strDesktop & "FILENAME.lnk")
End If
How do you execute the vbs post install?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Most likely does not work in vista due to security, maybe you need to run the vbs with admin permissions.