Scripts Thread, Adding new printers based on IP Address in Coding and Web Development; I made this recently for a customer, maybe someone will find it useful. As with most scripts used in the ...
22nd August 2011, 10:14 PM #1
- Rep Power
Adding new printers based on IP Address
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.
IDG Tech News
By Andi in forum Thin Client and Virtual Machines
Last Post: 3rd September 2008, 11:19 AM
By projector1 in forum Windows
Last Post: 19th May 2008, 01:24 PM
By NeoNemesis in forum Windows
Last Post: 6th August 2007, 09:03 AM
By ICTNUT in forum Scripts
Last Post: 13th May 2006, 09:19 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)