Script for printer selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I work in multiple locations from the same laptop running XP accessing the
same server based applications. The server is configured to print to my
default printer (which is different at each location). The server will not
recognize a change in default printer after login. If I forget to change my
default printer for a location (before I log in to the remote app), I have to
log out, change the default printer and log back in. Can someone recommend
some sort of script that will prompt me at boot or at least before any
programs are loaded) for my current location and set the default printer
based on that location, or at least, prompt me to select the default printer?
 
try this script( you can put on logon script) - it will set the default
printer based on IP of workstation if is 10.1.xxx.xxx then set printer1 if is
10.2.xxx.xxx then set printer2:

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objItem in colItems
strIPAddress = objItem.IPAddress(0)
arrIPAddress = Split(strIPAddress, ".")

If arrIPAddress(0) = "10" Then

Select Case arrIPAddress(1)
Case 1
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Name = 'printer1'")
For Each objPrinter in colInstalledPrinters
objPrinter.SetDefaultPrinter()
Exit For
Next
Case 2
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Name = 'printer2'")
For Each objPrinter in colInstalledPrinters
objPrinter.SetDefaultPrinter()
Exit For
Next
End Select
End If
Next
 
Back
Top