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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s