Icons not being deleted using 'objFSO.DeleteFile()'
I have a VBScript that should delete all users desktop icons and replace
them with a clean version, but for some reason it is not deleting.
If I manually delete, the icons are copied. However if I comment out the
copy line, and then run the script, they are not deleted. No error occurs.
Can somebody please suggest what the problem might be? Thanks.
'****************************************************
'* Logon Script File For Users in the DD Domain *
'* Purpose: Ensure required icons are on desktop *
'****************************************************
Option Explicit
Dim objFSO ' A File System object (for checking
files/folders exist, copying, and deleting)
Dim objShell ' A shell object (for accessing special folders)
Dim user_name ' The user name of the currently logged in user
Dim i ' Dummy for looping
'****************************************************
'* Create the required desktop icons *
'****************************************************
' Set the desktop folder location
Set objShell = WScript.CreateObject("WScript.Shell")
desktop_location = objShell.SpecialFolders.Item("Desktop")
' Set the location where the files to copy can be found
desktop_icon_store = "\\videss\Shortcuts\Desktop\"
'Check that the users desktop location exists
If (objFSO.FolderExists(desktop_location)) Then
' Delete all files in the desktop folder
objFSO.DeleteFile(desktop_location & "*.*")
' Copy all files to the desktop folder
objFSO.CopyFile desktop_icon_store & "*.*", desktop_location, True
End IF
'****************************************************
'* Reset the objects and exit *
'****************************************************
Set objFSO = Nothing
Set objShell = Nothing
WScript.Quit
No comments:
Post a Comment