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

Redirect Command line utility output to variable? 1

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
US
I have written a script that executes the Microsoft Repadmin command to force AD replication. I need to grab the results from it so I can use an InStr to determine if it ran successfully or not.

Can anyone help me? For simplicity sake of an example how about we use this code

Code:
WSHShell = Createobject("Wscript.Shell")
Call WSHShell.Run("CMD.EXE /C DIR C:")

How can I get what would be displayed as the Dir results to be an array that I could loop through? I think I want to use stdIN but am not sure how to do it.

I hope you find this post helpful.

Regards,

Mark
 
Set oShell = CreateObject ("WScript.Shell")
Set oExec = oShell.Exec("CMD.EXE /C DIR C:")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
myArray = Split(oExec.StdOut.ReadAll, vbCrLf)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Exactly what I needed. Many thanks PHV.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top