i have a peice of code i hamburgered together from here and there. I am no code writer but i am trying to pick it up but for now its duct tape and coathangers for me....
I am trying to output the results of the del command im issuing so that i can end up with a report of what was deleted/not deleted... Once i figure out how to output the results correctly i may try it on other commands within the script.
Right now i am able to get the script to create the txt file and write a couple comments into it but the actual "results" of the commands within i need help being able to output into the txt file.
here is the code now:
I am trying to output the results of the del command im issuing so that i can end up with a report of what was deleted/not deleted... Once i figure out how to output the results correctly i may try it on other commands within the script.
Right now i am able to get the script to create the txt file and write a couple comments into it but the actual "results" of the commands within i need help being able to output into the txt file.
here is the code now:
Code:
Dim objOutputFile
Dim strOutputFile
Dim oFSO
Const OPEN_FILE_FOR_APPENDING = 8
strOutputFile = "c:\delfiles.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
objOutputFile.WriteLine "Starting script"
For Each strWorkstation In RemotePC
objOutputFile.WriteLine "Doing actions for " & strWorkStation
Call WSHShell.Run("cmd.exe /c del \\"& strWorkstation &"\c$\*.nsf /s")
Call WSHShell.Run("cmd.exe /c del \\"& strWorkstation &"\c$\*.xls /s")
Call WSHShell.Run("cmd.exe /c del \\"& strWorkstation &"\c$\*.doc /s")
next
objOutputFile.Close