[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How do I stop the PushPrinterConnections scripts from running multiple times?

Posted on 2008-01-29
7
Medium Priority
?
301 Views
Last Modified: 2012-05-05
Hello;  weve set up some printers using GPO and the Printer Management functions of R2.  Our problem is that the PushPrinterConnections script runs on the machines every time they boot, whether the machine has the printer already installed or not.  Have any of you run into this problem, and if so, howd you resolve it?   Its not a major issue; but it is generating some noise from users who are in multiple OUs, and getting multiple scripts every day.  Any advice would be appreciated, thanks.
0
Comment
Question by:Vegah_man
  • 4
  • 3
7 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 20773851
Hi, my suggestion would be to modify the script to check EnumPrinterConnections:
http://msdn2.microsoft.com/en-us/library/zhds6k80(VS.85).aspx

         Set WshNetwork = WScript.CreateObject("WScript.Network")
         Set objPrinters = WshNetwork.EnumPrinterConnections
         WScript.Echo "Network printer mappings:"
         For i = 0 to objPrinters.Count - 1 Step 2
            WScript.Echo "Port " & objPrinters.Item(i) & " = " & objPrinters.Item(i+1)
         Next

This way, you would be able to check whether the particular printer has been mapped already, and not map it.  While this still means that you do *run* the script, it won't map printers if they're already there.

Something like:

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objPrinters = WshNetwork.EnumPrinterConnections
strCurrentPrinters = ";"
For i = 0 to objPrinters.Count - 1 Step 2
      strCurrentPrinters = strCurrentPrinters & UCase(objPrinters.Item(i+1)) & ";"
Next
strPrinterToMap = "\\server\printer"
If InStr(strCurrentPrinters, ";" & UCase(strPrinterToMap) & ";") = 0 Then
      WshNetwork.AddWindowsPrinterConnection strPrinterToMap
End If


Regards,

Rob.
0
 

Author Comment

by:Vegah_man
ID: 20777180
Thanks; but we're really looking to try and make it so he script doesn't run at all if they already have the printer(s).  We've tried using WMI filters on the GPO, but so far no luck.


Jason
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20780944
But what is your criteria for not running the script?  You still need to check if they have the printer mapped, right?  So you'll have to run a script (or query, if you like), against the computer anyway, and you may as well do this at the top of the existing script, so you don't to execute "another" script.

I don't see much point in creating another script to check if the printer is installed, and if they are, don't run the extra script, but if not, do run the printer mappings....

Regards,

Rob.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:Vegah_man
ID: 20781265
Ok, the long and short of it is that we had a Kix logon script that had gotten quite massive over the years; and part of it was deploying printers.  So we started using the R2 Printer Management to deploy them thru group policy.  This works great in 95% of the environment, but we've got some users who are in multiple OU's, and thus get multiple ppc scripts running every morning.

Our original goal was to use the printer management to deploy thru group policy, to cut back on the time users sit staring at scripts in the morning.  Unfortunately, with some users, we've just switched the scripts they're staring at.  That's why we tried using a WMI filter on the GPO, so that if they had the printer, the script wouldn't run at all.  Does that make more sense?

jason
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 20782667
Well yes, I does make sense.  I understand that you want scripts to take the least amount of time possible, but to do this, you really have to determine what *is* taking the longest amount of time.

Running a local query like EnumPrinterConnections, and checking string values is going to be a lot faster that re-mapping already mapped printers.  Let's say the first time a user logs in, they will get printers mapped, which will take, say, 15 seconds.  The second time they log on, if you determine that the printer is already installed via EnumPrinterConnections, then you don't run objNetwork.AddWindowsPrinterConnection, and the script would only take about 2 seconds.

Either way, you need some way of determining whether a printer is installed, and this is the only way I know of.

I could help you with other aspects to try to speed things up, if you like.

Regards,

Rob.
0
 

Author Closing Comment

by:Vegah_man
ID: 31426118
Thanks for your help.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20792057
No problem. Thanks for the grade. I hope you get it sorted...

Regards,

Rob.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Today, unlike web development, the mobile landscape is complex enough for a software engineer and Android is posing more challenging environment thanks to its fragmentation issues on hardware and software fronts.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Screencast - Getting to Know the Pipeline

611 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question