Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DHCP reservations using NETSH

Status
Not open for further replies.

comdok

IS-IT--Management
May 22, 2012
1
US
I usually write batch files, but was wondering if anyone can tell me how to use the NETSH command in VBS.

Dim ServerName 'Server Name
Dim Scope 'scope
Dim ip 'ip of reservatio to be made
Dim MAC 'MAC address
Dim hostName 'Device hostname
ServerName = InputBox("Enter name of Server")
Scope = InputBox("Enter Scope")
ip = InputBox("Enter IP to reserve")
MAC = InputBox("Enter MAC")
hostname = InputBox("Enter Printers hostname")

An example of the command i want use is:

netsh Dhcp Server 10.0.0.1 Scope 10.0.0.0 Add reservedip 10.0.0.11 00AA11BB22CC "compname.domain.local" "compname.domain.local" "BOTH"

Executing the CMD file add the reservations to DHCP matching the IP address and MAC to the computer name. The computer name is listed twice so that it is the Reservation name and the description
 
Looks like you have all of what you need accept the following:

Code:
Set WSHShell = Createobject("Wscript.Shell")
WSHShell.Run "netsh Dhcp Server " & ServerName & " Scope " & Scope & " Add reservedip " & IP & " " & MAC & " " & Chr(34) & hostname & Chr(34) & " BOTH"

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top