Announcement

Collapse
No announcement yet.

change from DHCP to Static IP address

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • change from DHCP to Static IP address

    hi,

    I found a script at microsoft website that changes from DHCP to Static IP address according to the place where the user is.
    This is exactly what I wanted to but I didn't want to give users any administrator rights.

    Is it possible to run the script and change the IP configuration without administrator rights?

    here's the script:

    On Error Resume Next

    Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
    Set colNicConfigs = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
    Set colArgs = WScript.Arguments
    strLocal = LCase(colArgs(0))
    Select Case strLocal
    Case "sede" SetSede
    Case "agueda" SetAgueda
    End Select

    '************************************************* *****************************
    Sub SetSede

    For Each objNicConfig In colNicConfigs
    If Not objNicConfig.DHCPEnabled Then
    intReturn = objNicConfig.EnableDHCP
    Err.Clear
    End If
    Next

    End Sub

    '************************************************* **
    Sub SetAgueda

    arrIPAddresses = Array("192.168.11.100")
    arrSubnetMasks = Array("255.255.255.0")
    arrDefaultGateways = Array("192.168.11.254")
    arrGatewayCostMetrics = Array(1)
    arrDNSServers = Array("192.168.10.10")

    For Each objNicConfig In colNicConfigs
    If objNicConfig.DHCPEnabled Then
    intStaticReturn = objNicConfig.EnableStatic(arrIPAddresses, arrSubnetMasks)
    If intStaticReturn = 0 Then
    Set objNicChanged = objWMIService.Get _
    ("Win32_NetworkAdapterConfiguration.Index=" & objNicConfig.Index)
    intGatewaysReturn = objNicChanged.SetGateways(arrDefaultGateways, _
    arrGatewayCostMetrics)
    intDNSServers = objNicChanged.SetDNSServerSearchOrder(arrDNSServer s)
    End If
    End If
    Next

    End Sub

  • #2
    run it as a startup script via a GPO...
    Marcel
    Technical Consultant
    Netherlands
    http://www.phetios.com
    http://blog.nessus.nl

    MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
    "No matter how secure, there is always the human factor."

    "Enjoy life today, tomorrow may never come."
    "If you're going through hell, keep going. ~Winston Churchill"

    Comment

    Working...
    X