Question : Automate DHCP client computer add/remove via command line on Windows 2003 DHCP Server

We have a Windows 2003 server as DHCP server. Its a pain to enter in each MAC address and info by hand, I would like to automate the process. There are 4 fields that concern me and are necessary, the fifth field is optional to code. The list is below, its what the DHCP snap-in has...but I need this to be via commandline so I can automate it.

1. DHCP Reservation Name
2. MAC Address
3. IP Address
4. DHCP Description
5. (optional) Choice of DHCP/BOOTP/BOTH

Please tell me the cmd / exe with some sample info filled in (dhcp server, client info, etc).

Thanks

Answer : Automate DHCP client computer add/remove via command line on Windows 2003 DHCP Server

atkfrg56

I suggest you look into writing code with DHCPOBJS.DLL from the Windows 2000 Resource Kit.
This code will create a reservation:

Sub CreateDHCPReservations()

    ' Error handler, rem out for debugging
    On Error Resume Next

    ' Connect to the Target DHCP Server
    Set oDHCPServer        = oDHCPManager.Servers.Connect(strTargetDHCPServer)
   
    ' Create new Reservation Object
    strExecute            = "Set oDHCPReservation = oDHCPServer.Scopes(""" & strIPReference & """).Reservations.CreateNew"
    Execute(strExecute)
   
    With oDHCPReservation
   
        .Name        = strReservationName
        .UniqueID    = strReservationMAC
        .Address    = strReservationIP
        .Comment    = strReservationDescription
        .Update
   
    End With
   
    ' Close connection to DHCP Server
    oDHCPServer.Disconnect
   
End Sub

Cheers

JamesDS
Random Solutions  
 
programming4us programming4us