Link to home
Start Free TrialLog in
Avatar of PLSM
PLSMFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VBS run dos command problem

Hi.

srvinfo.exe is a W2K Resource Kit program that will list all sorts of information about local and remote computers. I cannot get the below VBS to work. It is supposed to open a dos prompt, run a command, write the results to a file, then close the dos prompt. Any suggestions?

--------------------------
Option Explicit
Dim fso, ts, strComputer, objShell, iReturn, objCommand
Const ForReading = 1
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
' CHANGE THE PATH ON THE NEXT LINE
Set ts = fso.OpenTextFile("C:\Documents and Settings\user\Desktop\SDService\serverlist.txt", ForReading)

Do While Not ts.AtEndOfStream
  strComputer = Trim(ts.ReadLine)
Set objCommand = WScript.CreateObject ("srvinfo -nf \\" & strComputer & " > C:\Documents and Settings\User\Desktop\SDService\Results\" & strComputer & ".txt")
Set objShell = wscript.createObject("wscript.shell")
iReturn = objShell.Run ("%comspec% /C objCommand",1,True)
Loop

ts.Close
Set ts = Nothing
Set fso = Nothing
-----------------------------------

Thanks

PLSM
Avatar of sirbounty
sirbounty
Flag of United States of America image

Hmm-you might try including the full path to srvinfo, and/or preceding that command by
CMD /C srvinfo...
ASKER CERTIFIED SOLUTION
Avatar of PLSM
PLSM
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial