从具有多个用户的远程计算机中删除快捷方式



警告我没有VB knoeledge

所以我今天早上发现了一个方便的脚本:

InputFile = "C:MachineList.Txt"
Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(InputFile)
Do While Not (objFile.AtEndOfStream)
strComputer = objFile.ReadLine
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("\" & strComputer & "c$Documents and Settingsall usersDesktopMalwarebytes Anti-Malware.LNK")
Err.Clear
Loop
MsgBox "Done"

它做得很好。我面临的问题是,快捷方式并不总是在所有用户下,或者他们的名字让我们称之为user1

所以我希望它能浏览MachineList.txt,浏览所有的配置文件,搜索Malwarebytes Anti-Malware.LNK。我已经看到了一些关于这个的脚本,但我只是无法理解VB是很短的时间。我感谢您的意见。

我假设您提供的结果是有效的路径。。。因此,这应该起作用:

InputFile = "C:MachineList.Txt"
Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(InputFile)
Do While Not (objFile.AtEndOfStream)
strComputer = objFile.ReadLine
For Each objsubfolder In objFSO.GetFolder("\" & strComputer & "c$Documents and Settings").subfolders
If objFSO.FileExists(objsubfolder.Path & "desktopMalwarebytes Anti-Malware.LNK") Then
objFSO.DeleteFile (objsubfolder.Path & "desktopMalwarebytes Anti-Malware.LNK")
End If
'To check another file uncomment this
'Add as many of these as you like here
'If objFSO.FileExists(objsubfolder.Path & "desktopOtherfile.LNK") Then
'    objFSO.DeleteFile (objsubfolder.Path & "desktopOtherfile.LNK")
'End If
Next
Loop
MsgBox "Done"

最新更新