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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS: launch batch file from pc list

Status
Not open for further replies.

rodrigez

Technical User
Jan 7, 2011
2
IT
hi guys!
have any problem with my vbs. this is the code:

Dim fso, SourceFolder, wshShell

Set fso = CreateObject("Scripting.FileSystemObject")
SourceFolder = "C:\Tools\PsTools"


Set ReadFile = fso_OpenTextFile("C:\Tools\PsTools\elencoserver.txt")


If (fso.fileexists("C:\Tools\PsTools\Check.log")) then
Set LogFile = fso_OpenTextFile("C:\Tools\PsTools\Check.log",8)
Else
Set LogFile = fso.CreateTextFile("C:\Tools\PsTools\Check.log", TRUE)
End If

Set wshShell = WScript.CreateObject ("WScript.Shell")
wshShell.run "CMD /C C:\Tools\PsTools\psexec @eserverlist.txt -c remdir.bat"

Do while Not LeggiFile.AtEndOfStream
CurrentServer = ReadFile.ReadLine

If Err.Number <> 0 then
LogFile.WriteLine (CurrentServer & " Error!")
Err.clear
End if
Loop


Set wshShell = Nothing

Set fso = Nothing


I'd like that it runs, launch remdir.bat (delete some folders), write on check.log results, and if there is an error, it write "Server XXX Error!".
Now it runs, del folders but the check.log is empty...

please can you help me??

sorry for my ugly english.. ;)

Tks a lot!!!
 
Anyway, what is LeggiFile ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
it's not clear what you're trying to do here.
you have one command to execute remdir.bat
then you have a loop that READS through a file!
reading each line and if there's AN ERROR!?
writes something to a log file?
do you mean error in reading the line?
that's what it sounds like.
can you be a little more clear?
 
sorry wvdba, but I don't know VBScript language.. I have recovery these information by network..

Now I have this code:

Dim fso, wshShell

Set fso = CreateObject("Scripting.FileSystemObject")

Set ReadFile = fso_OpenTextFile("C:\Tools\PsTools\serverlist.txt")

Set wshShell = WScript.CreateObject ("WScript.Shell")
wshShell.run "CMD /C C:\Tools\PsTools\psexec @serverlist.txt -c remdir.bat"


Set wshShell = Nothing

Set fso = Nothing


This script launch remdir.bat that delete some folder from serverlist.txt. From this script, i'd like see the result in log file for each server. I can filter manually, it's no problem. It's possible? If yes, how?? can u help me, please?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top