Hey guys I have a script i want to use but it doesnt allow me to output the results of the RM command i have in here. Someone, anyone know how to output these results if the folder was not found or successfully deleted?
Thanks much for input!!!
Thanks much for input!!!
Code:
'nsf search and destroy and folder remove
Dim objOutputFile
Dim strOutputFile
Dim oFSO
Const OPEN_FILE_FOR_APPENDING = 8
strOutputFile = "logs\delresults.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
Set oTextStream = oFSO.OpenTextFile("passlist.txt")
Set objOutputFile = oFSO.OpenTextFile(strOutputFile, OPEN_FILE_FOR_APPENDING, True)
RemotePC = Split(oTextStream.ReadAll, vbCrLf)
oTextStream.Close
For Each strWorkstation In RemotePC
objOutputFile.WriteLine "Deleting files and folders on "& strWorkStation
Call WSHShell.run("cmd.exe /c del \\"& strWorkstation &"\c$\*.nsf /s >> "& strOutputFile)
objOutputFile.Close
Set objOutputFile = oFSO.OpenTextFile(strOutputFile, OPEN_FILE_FOR_APPENDING, True)
objOutputFile.WriteLine "Deleting Selected folders on "& strWorkStation
Call WSHShell.run("cmd.exe /c RD /S /Q ""\\"& strWorkstation &"\c$\New Folder\"" >> "& strOutputFile)
next
objOutputFile.Close