I made this recently for a customer, maybe someone will find it useful. As with most scripts used in the world, this is not entirely new source and was not created by me 100%. If I remember where I got the bulk of it, I will credit the author(s).
'execute an ipconfig to the local machine and store the ouput in the stdout text stream
Set objShell = CreateObject("Wscript.Shell")
set objNetwork = WScript.CreateObject("WScript.Network")
set objExec = objShell.Exec("%comspec% /c ipconfig.exe")
'loop through the stream looking for key phrase "IPv4 Address"
do while NOT (objExec.Stdout.AtEndOfStream)
strLine = objExec.Stdout.ReadLine
if(inStr(strLine, "IPv4 Address")) then
'Parse strLine to obtain IP.
strIP = trim(right(strLine, len(strLine) - inStrRev(strLine, ":")))
arrTokens = split(strIP, ".")
select case arrTokens(2)
'3rd token/octet'If the client IP address is X.X.100.X map Printer_1, wait for 2 seconds then make Printer_1 the default
'If the client IP address is X.X.200.X map Printer_2 and Printer_3, wait for 2 seconds then make Printer_3 the default
'If the client IP address is X.X.300.X map Printer_4, wait for 2 seconds then make Printer_4 the default
If you are running Windows XP, you will need to replace "IPv4 Address" with just "IP Address" to make it work.
There are currently 1 users browsing this thread. (0 members and 1 guests)