How do I change this .bat code to VBScript?

Nathan Pabst
Nathan Pabst used Ask the Experts™
I am trying to convert a .bat file to a VBScript file for convenience.  I have been able to convert all parts, except the following:

Echo DateTime=%DATE%, %TIME% > "networklocation\System.log"
Echo USERDOMAIN=%USERDOMAIN%\%USERDNSDOMAIN% >> "networklocation\System.log"
Echo COMPUTERNAME=%COMPUTERNAME% >> "networklocation\System.log"
Echo USERNAME=%USERNAME% >> "networklocation\System.log"
ipconfig >> "networklocation\System.log"
systeminfo | find /I "tImE" >> "networklocation\System.log"

Open in new window

I understand that this is appending the data to a log file, but I don't know how to write the "Echo", "ipconfig", and "systeminfo" commands in VBScript.  Any help is appreciated.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Test your restores, not your backups...
Top Expert 2016
Here's an example for systeminfo, should give you the idea.  Maybe you want to build a small function that does this for a passed parm of the command to run.  Questions welcome.

' Constants for Wscript.Exec status
Const WshRunning = 0
Const WshFinished = 1
Const WshFailed = 2

' Command line EXE to run
strCommand = "systeminfo"

' Execute the command
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec(strCommand)

' Wait for it to finish
Do While WshShellExec.Status = WshRunning
     WScript.Sleep 100

' Capture STDOUT or STDERR to variable
Select Case WshShellExec.Status
   Case WshFinished
       strOutput = WshShellExec.StdOut.ReadAll
   Case WshFailed
       strOutput = WshShellExec.StdErr.ReadAll
End Select

' Display on console for testing, could use in a write to a log
WScript.Echo strOutput

Open in new window

Daryl BamforthTechnical Expert

Don't if at all possible!

Seriously, get up to speed on Powershell it should be the default language of any windows sys admin these days.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial