Delete Shortcuts from All Users profile directory

This script was written to delete a list of shortcuts from the “All Users” profile directory on windows.

'This script will delete a list of windows shortcuts that are in
'the "All Users" profile directory on Windows.
'
'Written by Chris Woollard (2009)

Dim objFSO, objWSH
Dim strAllUsersProfile, strAllUsersFolder
Dim strFileList, strFilesToDeleteArray,strFileToDelete

'On Error Resume Next    ' this is set because the file(s) may be locked.
strFileList		 = "Citrix XenApp.lnk,Blackberry Manager.lnk"
strFilesToDeleteArray    = split(strFileList,",")

'Declare objects
Set objFSO    = CreateObject("Scripting.FileSystemObject")
set objWSH    = CreateObject("WScript.Shell")

' Get the "All Users" profile folder path then determine parent folder.
strAllUsersFolder    = objWSH.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")

'Look through each user profile folder to determine which file to delete.
For Each strFileToDelete in strFilesToDeleteArray
	if objFSO.FileExists(strAllUsersFolder & _
		"\Start Menu\Programs\Startup\" & strFileToDelete) THEN
	objFSO.DeleteFile(strAllUsersFolder & _
		"\Start Menu\Programs\Startup\" & strFileToDelete),TRUE
	End If
Next

' Clean up
set objFSO = Nothing
set objWSH = Nothing

Leave a comment