Link to home
Create AccountLog in
Avatar of cmkeur
cmkeurFlag for United States of America

asked on

logon script for specific DHCP scope

Any way to specify a logon script for a dchp scope based only on the DHCP scope?
Not all computers are on domain and some are set to auto login so GP doesn't work.
Avatar of TheGorby
TheGorby
Flag of United States of America image

This link describes how to use VBS to obtain the IP address of a computer, or just one of the 4 octets of that IP address. I recommend using the GetIPOctet fucntion to check if the octet matches one from your specific scope:

http://www.codeproject.com/KB/vbscript/ipaddress.aspx

If you need more assistance with the actual script itself, just let me know.
Avatar of cmkeur

ASKER

not sure how to implement that.  I was thinking that when a computer requests a DCHP lease from the scope in question a netuse cmd gets pushed out to it.
Can you explain how that code is used in that scenario
Avatar of Ernie Beek
Here is an example that may help using the IP address as a range.  This would mean anything 192.168.100.* would get one printer while 192.168.0.* would get another...

Hope this helps
Dim strComputer,strIPAddress,strIPRange
Dim objNetwork
Dim IPConfigSet, IPConfig
Dim arrIPAddress

strComputer = "."

Set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" _ 
 & strComputer & "/root/cimv2").ExecQuery("select IPAddress from " _ 
 & "Win32_NetworkAdapterConfiguration where IPEnabled=True") 
 
Set objNetwork = WScript.CreateObject("WScript.Network")

For Each IPConfig In IPConfigSet
     If Not IsNull(IPConfig.IPAddress) Then
          arrIPAddress = split(IPConfig.IPAddress(0) ,".")
          strIPRange = arrIPAddress(0) & "." & arrIPAddress(1) & "." & arrIPAddress(2) & ".0"	
          select case strIPRange
               case "192.168.100.0"
                    objNetwork.AddWindowsPrinterConnection "\\server\printer"
               case "192.168.0.0"
                    objNetwork.AddWindowsPrinterConnection "\\server\printer"
          end select
     end if
next

set objNetwork = nothing
set IPConfigSet = nothing

Open in new window

Avatar of cmkeur

ASKER

lcaldwell, where does the script "go"? how does it get triggered?
Script goes into your login script... It is triggered every time the user logs onto the network.... Alternatively if you do not have a domain controller for login scripts you could put it on each computer and execute upon login, but thats messy..  Domain Controller with login script is the way to go..
Avatar of cmkeur

ASKER

ok, that gets me 50% there, some of the machines that need the network share aren't on the domain and are set to auto login, they only get a DCHP lease.  Any way to tackle that one?
ASKER CERTIFIED SOLUTION
Avatar of ICaldwell
ICaldwell
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of cmkeur

ASKER

ok thanks. ill try that and get back shortly.