The script below is snippts from my own laptop configuration program that
runs on boot up that does what you want. If you are interested in the entire
script (which sets where I am based on IP address, changes INI files, runs
apps, and more based on an INI file) email me.
good luck,
todd
***** BEGIN PYTHON SCRIPT *******
import types, pprint
import win32api, win32con, win32print
DEBUG = 1;
def GetPrinters():
'''Gets local printers into printers list'''
printers = []
try:
plist = win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL |
win32print.PRINTER_ENUM_CONNECTIONS, '')
for p in plist:
printers.append(p[2])
return printers
except:
print 'Error Enumerating Printers'
def ChangeDefaultPrinter(printer):
if type(printer) == types.StringType:
try:
win32print.SetDefaultPrinter(printer)
print ' Default Printer set to: %s' % printer
except:
print ' Specified printer %s not available' % printer
raise
else:
print ' Default printer not set, no printers available'
# get a list of printers on the system
printers = GetPrinters()
# print out list of printers
pprint.pprint(printers)
# change printer (example on my work network)
ChangeDefaultPrinter(r'\\PDC_CCTI\HP LaserJet 4050 Series PCL 6')
***** END PYTHON SCRIPT *******
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Advice from Kids:
Don't sneeze in front of Mom when you're eating crackers.
-- Mitchell, Age 12
Todd Palmer
Senior Software Engineer
CallCenter Technology Inc
[EMAIL PROTECTED]
http://CallCenterTechnology.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython