?
Solved

Run Command in VBS

Posted on 2012-08-13
5
Medium Priority
?
1,942 Views
Last Modified: 2012-09-05
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.
0
Comment
Question by:Mdc2050
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:LazyFolk
ID: 38287490
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
 

Author Comment

by:Mdc2050
ID: 38288351
Hi, that didnt work.  I get Type mismatch 'shell'

:(
0
 
LVL 5

Expert Comment

by:LazyFolk
ID: 38290992
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
 
LVL 31

Accepted Solution

by:
MegaNuk3 earned 2000 total points
ID: 38293381
Try:
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run("%comspec% /C netsh interface ip set address...")
0
 
LVL 31

Expert Comment

by:MegaNuk3
ID: 38293397
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question