WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE COM ADO CDO ADSI LDAP
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

IPCONFIG Results From STDOUT


Question:

I would like to get the results of ipconfig from stdout. I found some WSH code. How can this be accomplished in WinBatch?
Set objShell = CreateObject("WScript.Shell")
Set objWshScriptExec = objShell.Exec("ipconfig /all")
Set objStdOut = objWshScriptExec.StdOut

'
' Skip first four lines
'
strLine = objStdOut.ReadLine
WScript.Echo strLine 
strLine = objStdOut.ReadLine
WScript.Echo strLine
strLine = objStdOut.ReadLine
WScript.Echo strLine
strLine = objStdOut.ReadLine
WScript.Echo strLine

'
' Add date/time information
'

strCurrentTime = "   Current Date/Time. . . . . . . . .: " & Now()
WScript.Echo strCurrentTime

'
' Display the rest of the output
'

While Not objStdOut.AtEndOfStream
   strLine = objStdOut.ReadLine
   WScript.Echo strLine
Wend

Answer:

Here is the quivalent WinBatch code:
objShell = ObjectOpen("WScript.Shell")
objWshScriptExec = objShell.Exec("ipconfig /all")
objStdOut = objWshScriptExec.StdOut


;Skip first four lines
line = ""
strLine = objStdOut.ReadLine
line = strCat(line,strLine,@CRLF) 
strLine = objStdOut.ReadLine
line = strCat(line,strLine,@CRLF) 
strLine = objStdOut.ReadLine
line = strCat(line,strLine,@CRLF) 
strLine = objStdOut.ReadLine
line = strCat(line,strLine,@CRLF) 


; Add date/time information


strCurrentTime = StrCat("   Current Date/Time. . . . . . . . .: " , TimeDate() )
line = strCat(line,strCurrentTime,@CRLF) 


; Display the rest of the output


While ! objStdOut.AtEndOfStream
   strLine = objStdOut.ReadLine
   line = strCat(line,strLine,@CRLF) 
Endwhile
Message("IPCONFIG OUTPUT", line)

Article ID:   W16070
File Created: 2004:03:30:15:42:42
Last Updated: 2004:03:30:15:42:42