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

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.
Vegah_manAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobSampsonCommented:
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
Vegah_manAuthor Commented:
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
RobSampsonCommented:
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
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Vegah_manAuthor Commented:
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
RobSampsonCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vegah_manAuthor Commented:
Thanks for your help.
0
RobSampsonCommented:
No problem. Thanks for the grade. I hope you get it sorted...

Regards,

Rob.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Printers and Scanners

From novice to tech pro — start learning today.