Re: Python script to install network printers

2005-10-05 Thread future_retro
These functions should get you started and probably finished...

def createprinterport(IPAddress,ServerName):
WBEM =
win32com.client.GetObject(rwinmgmts:{impersonationLevel=impersonate}!\\
+ ServerName + r\root\cimv2)
WBEM.Security_.Privileges.AddAsString(SeLoadDriverPrivilege)
printerport = WBEM.Get(Win32_TCPIPPrinterPort).SpawnInstance_()
printerport.Properties_('Name').Value = 'IP_'+IPAddress
printerport.Properties_('Protocol').Value = 1
printerport.Properties_('HostAddress').Value = IPAddress
printerport.Properties_('PortNumber').Value = '9100'
printerport.Properties_('SNMPEnabled').Value = 'False'
printerport.Put_()

def
createprinter(PrinterName,DriverName,Location,ShareName,IPAddress,ServerName):
WBEM =
win32com.client.GetObject(rwinmgmts:{impersonationLevel=impersonate}!\\
+ ServerName + r\root\cimv2)
WBEM.Security_.ImpersonationLevel = 3
WBEM.Security_.Privileges.AddAsString(SeLoadDriverPrivilege)
printer = WBEM.Get(Win32_Printer).SpawnInstance_()
printer.Properties_('DeviceID').Value = PrinterName
printer.Properties_('DriverName').Value = DriverName
printer.Properties_('Location').Value = Location
printer.Properties_('Network').Value = 'True'
printer.Properties_('Shared').Value = 'True'
printer.Properties_('ShareName').Value = ShareName
printer.Properties_('PortName').Value = 'IP_'+IPAddress
printer.Put_()

I also created one for migrating print drivers but had loads of
problems with it.  If the driver doesn't pass Microsoft logo testing
the scripts fail even if it is signed by Microsoft.  I never worked out
why there were 2 levels of protection.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python script to install network printers

2005-10-05 Thread future_retro
The target OS needs to support WMI so 2000 or XP.

-- 
http://mail.python.org/mailman/listinfo/python-list


Python script to install network printers

2005-10-04 Thread Matt Chan
Hi, I am trying to create a python script to install a set of network
printers. I have had success using an os.popen statement, using
rundll32 and printui.dll. This takes way too long. Can someone point
me in a quicker direction?

thanks,
Matt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python script to install network printers

2005-10-04 Thread Matt Darby
Matt Chan wrote:

Hi, I am trying to create a python script to install a set of network
printers. I have had success using an os.popen statement, using
rundll32 and printui.dll. This takes way too long. Can someone point
me in a quicker direction?

thanks,
Matt
  

I know this is the python mailinglist, but why not use some batch 
commands in a netlogon script? (assuming you're using Samba of course)

Matt Darby
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python script to install network printers

2005-10-04 Thread Roger Upole
You can use win32print.AddPrinterConnection(r'\\server\sharedprinter').
However, if the printer driver has to be copied to the client machine and
installed, that's probably where most of the time is spent.
   hth
  Roger

Matt Chan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
Hi, I am trying to create a python script to install a set of network
printers. I have had success using an os.popen statement, using
rundll32 and printui.dll. This takes way too long. Can someone point
me in a quicker direction?

thanks,
Matt 




== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 100,000 
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-- 
http://mail.python.org/mailman/listinfo/python-list