Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output results to txt file help

Status
Not open for further replies.

weezy6902

IS-IT--Management
Jun 2, 2003
46
0
0
US
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:
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

 
if you are just looking for an error code then perhaps you could set the optional 3rd parameters to the Run method.


iErrCode = WSHShell.Run("cmd.exe /c del \\"& strWorkstation &"\c$\*.nsf /s", 1, True)

Also consider using the Exec method instead of Run if this error code is not what you want.

 
whoa i got it another way but thanks for the reply!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top