We help IT Professionals succeed at work.

Run Command in VBS

Id like to run the following commands in vbs please.

netsh interface ip set address "AHDB LAN" static 192.168.0.10 255.255.255.0 192.168.0.254
netsh interface ip set dns "AHDB LAN" static 192.168.0.2

Can someone please tell me how please.

Thanks.
Comment
Watch Question

Commented:
tried this :

dim myCommand

myCommand = "netsh interface ip set address ""AHDB LAN"" static 192.168.0.10 255.255.255.0 192.168.0.254"
shell (myCommand)

myCommand = "netsh interface ip set dns ""AHDB LAN"" static 192.168.0.2"
shell (myCommand)

Open in new window

Author

Commented:
Hi, that didnt work.  I get Type mismatch 'shell'

:(

Commented:
Is this working better ?

Dim myCommand
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")

myCommand = "netsh interface ip set address ""AHDB LAN"" static 192.168.0.10 255.255.255.0 192.168.0.254"
strResult = wshShell.Run(myCommand)

myCommand = "netsh interface ip set dns ""AHDB LAN"" static 192.168.0.2"
Shell (myCommand)

Open in new window



If not, set myCommand to "netsh" and run it.
You should get a netsh prompt

If netsh works, the problem resides in the command (spaces, double quotes, ...)
Commented:
Try:
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run("%comspec% /C netsh interface ip set address...")