How do I change this .bat code to VBScript?

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.
Nathan PabstAsked:
Who is Participating?
 
Bill PrewConnect With a Mentor Commented:
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
Loop

' 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


»bp
1
 
Daryl BamforthTechnical ExpertCommented:
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.
1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.