Problems executing ipconfig command from VBScript

0

I'm having a problem trying to execute a command from VBScript that works correctly from the command line.

From CMD I successfully execute:

  

ipconfig / all | find / i "DHCP Server"

But from VBScript if I execute the following:

Dim	vIpConfig
vIpConfig = oShell.Exec("ipconfig /all | find /i ""Servidor DHCP""").StdOut.ReadAll

MsgBox(vIpConfig)

The MsgBox returns the error:

  

Error: unknown or incomplete command line.

That is, the command arrives but something in the syntax is incorrect and I do not realize what it is. I think I'm escaping the quotes correctly.

Thanks for your time.

    
asked by Guillermo 01.11.2018 в 15:09
source

1 answer

0

to paraser the character | or Chr (124) or hex 7C sees it as something else but you can try that and the result is the same:

Dim vIpConfig
Set oShell = CreateObject ("WScript.Shell") 
vIpConfig = oShell.Exec("ipconfig /all").StdOut.ReadAll
MsgBox(InStr(vIpConfig,"Servidor DHCP"))
    
answered by 01.11.2018 в 16:29