DHCP script help 
Author Message
 DHCP script help

I'm getting a runtime error in the script below. It uses dhcpobjs.dll.
Can anyone help please?

TIA,
Neville

'-----------------------------------------------------------

dim dhcpmanager, dhcpserver, dhcpscope, dhcpscopeoptions,
dim dhcpserveroptions, scopeobject
dim slocalipaddress, dhcpsvripaddress, scopeaddress, sscopeaddress
dim adapter, adapters, val

const defserver2="my-dc1"
const defserver3="my-dc2"

set dhcpmanager=wscript.createobject("dhcp.manager")

set adapters = getobject("winmgmts:")_
        .execquery("select * "_
        & "from Win32_NetworkAdapterConfiguration " _
        & "where IPEnabled=true")

for each adapter in adapters
  if adapter.dnsdomain="my.org.au" then
    dhcpsvripaddress=adapter.dhcpserver
    if isarray(adapter.ipaddress) then
        for each val in adapter.ipaddress
          slocalipaddress=split(val,".")
        next
    end if
  else
    dhcpsvripaddress=""
    localipaddress=""
  end if
next

set dhcpserver=dhcpmanager.servers.connect(dhcpsvripaddress)
set dhcpscope=dhcpserver.scopes

for i=1 to dhcpscope.count
  scopeaddress=dhcpscope(i).address
  sscopeaddress=split(scopeaddress,".")
  if slocalipaddress(0)=sscopeaddress(0) and _
      slocalipaddress(1)=sscopeaddress(1) then
        set dhcpscopeoptions=dhcpscope(i).options
        for j=1 to dhcpscopeoptions.count
          set scopeobject=dhcpscopeoptions(j)
          if not isarray(dhcpscopeoptions(j).value) then
            msgbox dhcpscopeoptions(j).value
            msgbox dhcpscopeoptions(j).name <<<<< Error occurs
          end if
        next
  end if
next

dhcpserver.disconnect
set dhcpmanager=nothing
set dhcpserver=nothing
set dhcpscope=nothing
set dhcpscopeoptions=nothing
set dhcpserveroptions=nothing

wscript.quit



Mon, 12 Dec 2005 09:26:38 GMT  
 DHCP script help
Could it be this  , comma on end of dim
dim dhcpmanager, dhcpserver, dhcpscope, dhcpscopeoptions, <<<<

Regards
Don Grover


Quote:
> I'm getting a runtime error in the script below. It uses dhcpobjs.dll.
> Can anyone help please?

> TIA,
> Neville

> '-----------------------------------------------------------

> dim dhcpmanager, dhcpserver, dhcpscope, dhcpscopeoptions,
> dim dhcpserveroptions, scopeobject
> dim slocalipaddress, dhcpsvripaddress, scopeaddress, sscopeaddress
> dim adapter, adapters, val

> const defserver2="my-dc1"
> const defserver3="my-dc2"

> set dhcpmanager=wscript.createobject("dhcp.manager")

> set adapters = getobject("winmgmts:")_
> .execquery("select * "_
> & "from Win32_NetworkAdapterConfiguration " _
> & "where IPEnabled=true")

> for each adapter in adapters
>   if adapter.dnsdomain="my.org.au" then
>     dhcpsvripaddress=adapter.dhcpserver
>     if isarray(adapter.ipaddress) then
> for each val in adapter.ipaddress
>   slocalipaddress=split(val,".")
> next
>     end if
>   else
>     dhcpsvripaddress=""
>     localipaddress=""
>   end if
> next

> set dhcpserver=dhcpmanager.servers.connect(dhcpsvripaddress)
> set dhcpscope=dhcpserver.scopes

> for i=1 to dhcpscope.count
>   scopeaddress=dhcpscope(i).address
>   sscopeaddress=split(scopeaddress,".")
>   if slocalipaddress(0)=sscopeaddress(0) and _
>       slocalipaddress(1)=sscopeaddress(1) then
> set dhcpscopeoptions=dhcpscope(i).options
> for j=1 to dhcpscopeoptions.count
>   set scopeobject=dhcpscopeoptions(j)
>   if not isarray(dhcpscopeoptions(j).value) then
>     msgbox dhcpscopeoptions(j).value
>     msgbox dhcpscopeoptions(j).name <<<<< Error occurs
>   end if
> next
>   end if
> next

> dhcpserver.disconnect
> set dhcpmanager=nothing
> set dhcpserver=nothing
> set dhcpscope=nothing
> set dhcpscopeoptions=nothing
> set dhcpserveroptions=nothing

> wscript.quit



Mon, 12 Dec 2005 10:48:56 GMT  
 DHCP script help
How many ip addresses are saved on the controller? maybe more than 512 ?

the count method of the dhcpobjs.dll crashs, if the controller have more
entries. maybe thats your problem.

I am thinking, the only one solution is: dhcpcmd.exe ;-) sorry



Mon, 12 Dec 2005 15:49:24 GMT  
 DHCP script help
Don, the comma wasn't the problem. The error occurred further down the
code as indicated.

Guido, I don't believe the number of IP addresses is the problem since
it works fine with the erroneous line commented out.



Tue, 13 Dec 2005 06:43:11 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. HELP with DHCP Objects

2. How to get IP for a COMPUTER on the DHCP, with a script

3. Scripting a DHCP Reservation

4. Manage in DHCP server by script

5. Script to change workstations to DHCP in NT environment

6. Help for reading IP of DHCP

7. QUICK HELP ..DHCP local IPaddress how to find ??

8. HELP: Changing Ip/DHCP address in VB

9. QUICK HELP ..DHCP local IPaddress how to find ??

10. QUICK HELP ..DHCP local IPaddress how to find ??

11. QUICK HELP ..DHCP local IPaddress how to find ??

12. HELP: Changing Ip/DHCP address in VB

 

 
Powered by phpBB® Forum Software