473,806 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python script to install network printers

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
Oct 4 '05 #1
3 6829
You can use win32print.AddP rinterConnectio n(r'\\server\sh aredprinter').
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" <en********@gma il.com> wrote in message news:ma******** *************** **************@ python.org...
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 =---
Oct 4 '05 #2
These functions should get you started and probably finished...

def createprinterpo rt(IPAddress,Se rverName):
WBEM =
win32com.client .GetObject(r"wi nmgmts:{imperso nationLevel=imp ersonate}!\\"
+ ServerName + r"\root\cimv 2")
WBEM.Security_. Privileges.AddA sString("SeLoad DriverPrivilege ")
printerport = WBEM.Get("Win32 _TCPIPPrinterPo rt").SpawnInsta nce_()
printerport.Pro perties_('Name' ).Value = 'IP_'+IPAddress
printerport.Pro perties_('Proto col').Value = 1
printerport.Pro perties_('HostA ddress').Value = IPAddress
printerport.Pro perties_('PortN umber').Value = '9100'
printerport.Pro perties_('SNMPE nabled').Value = 'False'
printerport.Put _()

def
createprinter(P rinterName,Driv erName,Location ,ShareName,IPAd dress,ServerNam e):
WBEM =
win32com.client .GetObject(r"wi nmgmts:{imperso nationLevel=imp ersonate}!\\"
+ ServerName + r"\root\cimv 2")
WBEM.Security_. ImpersonationLe vel = 3
WBEM.Security_. Privileges.AddA sString("SeLoad DriverPrivilege ")
printer = WBEM.Get("Win32 _Printer").Spaw nInstance_()
printer.Propert ies_('DeviceID' ).Value = PrinterName
printer.Propert ies_('DriverNam e').Value = DriverName
printer.Propert ies_('Location' ).Value = Location
printer.Propert ies_('Network') .Value = 'True'
printer.Propert ies_('Shared'). Value = 'True'
printer.Propert ies_('ShareName ').Value = ShareName
printer.Propert ies_('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.

Oct 5 '05 #3
The target OS needs to support WMI so 2000 or XP.

Oct 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
3217
by: dcrespo | last post by:
Hi all... Is there a way to print a PDF file directly from Python without having Acrobat installed? I know about ReportLab. It's a python module that lets you create almost any PDF document, but I still don't know if it supports printing, so I'm looking for a Python module that could do it. I want to print a PDF file just like if I were doing it from Acrobat. Daniel.
23
2571
by: anton.vredegoor | last post by:
Here's my situation: I'm typing this in a public library on a computer with OS windows 2000 server. I can run Internet explorer, word, excel and powerpoint, that's it. Maybe java, but it seems to be flaky. I want to run python scripts from this computer. At home I have a multi-computer network (from better times) but no internet access anymore, I could use this to try out solutions. I also have access to a friends computer which has...
0
1732
by: Sneid | last post by:
Hi I explain my title: i'm actually developping an application for privilege-limited users. They all have a laptop, and are not local administrators of the machine I 'm developping a program that allows them to create profiles with IP, Proxy, Network Drives and printers For drives and printers, they can supply a username/password so they can connect to file servers/printers without having to change the local user... (or do a RunAs, but...
0
1110
by: Martijn | last post by:
Hi, I created an application that installs network printers. Everything seems to work oke...but the printer is not set to default. I use the following line to install the printer Shell("rundll32 printui.dll,PrintUIEntry /y /if /b ""HP LaserJet 4000"" /f D:\Install\Drivers\HP4000\WinXP\hp222ip6.inf /r ""\\SSMD\" & pq & ".Printers.Amsterdam.NL.SSMD"" /m ""HP LaserJet 4000 Series PCL 6""")
2
6226
by: Tessa | last post by:
Hi, We have a .net web application, and are trying to use PrinterSettings.InstalledPrinters to list the printers installed on the webserver. (Windows 2003 server R2, IIS 6, .net framework 2.0.) The printers installed on the web server under the account used by asp.net for this web application are network printers that are shared by other computers that are on our domain. Permission has been granted for everyone to print to them. The...
5
6691
by: lmttag | last post by:
ASP.NET 2.0 (C#) application Intranet application (not on the Internet) Using Windows authentication and impersonation Windows Server 2003 (IIS6) Server is a member server on a domain Logged into server as a domain user that is in the local Administrators group on the server Workstation is on the same domain Logged into the workstation as a domain user, which is also in the local Administrators group on the server and workstation
5
4428
by: johnny | last post by:
Anyone know how I can make Machine A python script execute a python script on Machine B ?
15
3232
by: kyosohma | last post by:
Hi, I am trying to get a small group of volunteers together to create Windows binaries for any Python extension developer that needs them, much like the package/extension builders who volunteer their time to create Linux RPMs. The main thing I need are people willing to test the binaries to make sure the extension is stable. This would require installing the binary and probably downloading the source too to get the developer's test
0
19320
by: Python Nutter | last post by:
Mini install guide for python on the iPhone: Cydia =Install SSH helps make initial configuration easier until you get used to MobileTerminal Cydia =Install MobileTerminal (closest to a bash shell you get on your iPhone currently) Cydia =Install Finder (graphical alternative to using SSH/MobileTerminal for setting permissions, navigating file system, moving/copying files, etc.) Cydia =Install Python (currently installs CPython 2.5.1)
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10373
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.