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.
Mdc2050Asked:
Who is Participating?
 
MegaNuk3Connect With a Mentor Commented:
Try:
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run("%comspec% /C netsh interface ip set address...")
0
 
LazyFolkCommented:
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

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

:(
0
 
LazyFolkCommented:
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, ...)
0
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.