Running Shell Commands

I am trying to get the IPv4 address from the ipconfig program, as follows:

Dim ConfigData, FileLoc, cmd As String
Dim sh as Shell
sh = New Shell
Dim currentFolder as string
sh.timeout = 500000
sh.Mode = 2
cmd = “for /f ‘tokens=2 delims=:’ %%G IN (ipconfig ^| find 'IPv4') DO Result is %%G”
sh.execute(cmd)
msgbox(sh.Result)
currentFolder = SpecialFolder.CurrentWorkingDirectory.NativePath
FileLoc = currentFolder + “StulzCalc.exe”
sh.Execute FileLoc
Sh.Execute (“start http://”+ sh.Result)
Sh.Close

When I run the for command as shown in the CMD window it returns the correct information. I can’t seem to get it to do the same thing in the console program shown above. Any assistance would be appreciated.

You want Mode = 0, not 2.

Kem,

That doesn’t seem to make any difference. Actually I get a result that says “2 wasn’t expected at this time”

That means that it wants double quotes around the options. Get it working in a command shell first.

[code] Dim sh As New Shell
sh.Mode = 0
sh.TimeOut = 10000

Dim cmd As String = "FOR /F ““delims=: tokens=2"” %G IN (‘ipconfig ^| find "“IPv4"”’) DO @echo %G”

sh.Execute(cmd)

MsgBox sh.Result[/code]