0

我有一个 VBScript 应该删除所有用户桌面图标并用干净的版本替换它们,但由于某种原因它没有删除。

如果我手动删除,则会复制图标。但是,如果我注释掉复制行,然后运行脚本,它们不会被删除。不会发生错误。

有人可以建议问题可能是什么吗?

'****************************************************
'* 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
4

1 回答 1

1

这里有一个简单的答案,突然明白了 - 尾随\

将代码更改为此就可以了-

desktop_location = objShell.SpecialFolders.Item("Desktop") & "\"
于 2013-09-13T10:12:30.030 回答