Solved

Windows 7 Printer Installation Script

Posted on 2010-09-02
5
1,204 Views
Last Modified: 2012-05-10
Currently running the following script to add network printers shared on a Windows 2003 DC to Windows 7 Pro x64 workstations:

Set objNetwork = CreateObject("WScript.Network")

        objNetwork.AddWindowsPrinterConnection "\\server\printer1"
        objNetwork.AddWindowsPrinterConnection "\\server\printer2"
        objNetwork.AddWindowsPrinterConnection "\\server\printer3"

There is a bug where the script causes the screen to go black on the Win7 workstations when running, sometimes.  It eventually shows the desktop and the printers have installed, but it can take 2-10 minutes.  I know there is code to say "if printer exists, don't try and add it again".  That's what I think I need to avoid this issue each time the workstations login a simple if-then statement for the printer installation code above.  If I remove the script from the GPO the black screens stop appearing.
0
Comment
Question by:sc456a
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:TimAllan
ID: 33594336
It sounds like it's trying to find the path to your print server, which it is, but it's taking its time.
Just as a test, try using the full path to the print server

eg.
\\server.mydomain.com\printer1

instead of using the IP address or the just the server name
0
 
LVL 8

Accepted Solution

by:
spinzr0 earned 500 total points
ID: 33597493
For windows vista, I used to have an issue with permissions causing random delays and errors.  I wrote this function to get passed it.
Sub SetPrinterPermissionsSettings()

    On Error Resume Next



    Const ADS_RIGHT_GENERIC_ALL       = &h10000000

    Const ADS_ACETYPE_ACCESS_ALLOWED  = 0

    Const  ADS_PATH_REGISTRY          = 3

    Const  ADS_SD_FORMAT_IID          = 1



    Set oWShell = CreateObject("Wscript.Shell")

    oWShell.RegWrite "HKCU\Printers\LegacyPointAndPrint\DisableLegacyPointAndPrintAdminSecurityWarning", 1, "REG_DWORD"

    Set oWShell = Nothing



    sRegKey = "HKCU\Printers\LegacyPointAndPrint"

    

    Set dacl = createobject("AccessControlList")

    Set sd = createobject("SecurityDescriptor")

    Set newAce1 = CreateObject("AccessControlEntry")

    Set newAce2 = CreateObject("AccessControlEntry")

    Set ace = CreateObject("AccessControlEntry")

    Set sdutil = createobject("ADsSecurityUtility")



    Set sd = sdUtil.GetSecurityDescriptor (sRegKey, ADS_PATH_REGISTRY, ADS_SD_FORMAT_IID)

    Set dacl = sd.DiscretionaryAcl



    For Each ace in dAcl

        dacl.RemoveAce ace

    Next

    newAce1.Trustee = "NT AUTHORITY\SYSTEM"

    newAce1.AccessMask = ADS_RIGHT_GENERIC_ALL



    newAce1.AceType = ADS_ACETYPE_ACCESS_ALLOWED

    dacl.AddAce newAce1



    newAce2.Trustee = "Administrators"

    newAce2.AccessMask = ADS_RIGHT_GENERIC_ALL



    newAce2.AceType = ADS_ACETYPE_ACCESS_ALLOWED

    dacl.AddAce newAce2

    sdutil.SetSecurityDescriptor sRegKey, ADS_PATH_REGISTRY, sd, ADS_SD_FORMAT_IID



    Set dacl = Nothing

    Set sd = Nothing

    Set newAce1 = Nothing

    Set newAce2 = Nothing

    Set ace = Nothing

    Set sdutil = Nothing

End Sub

Open in new window

0
 
LVL 1

Author Comment

by:sc456a
ID: 33597572
Tim: It's not a path or DNS issue, the workstations can pull it up immediately if you type that into Explorer.  It's probably a driver issue related to x64 being on the workstations and x64 printer drivers being wonky on some of the printers, but it will install after a long delay.

spinzr0: I have no idea what that script does - some I'm askeered to try it. :)  Can you break it down for me?
0
 
LVL 8

Expert Comment

by:spinzr0
ID: 33597604
Yes.  There is a security warning set off witha printer where the driver is being downloaded from the printer server.  This bypasses that security warning.
0
 
LVL 1

Author Comment

by:sc456a
ID: 33722662
You were right about the warnings being the cause, although I didn't try your script - it was faster to just run the VBS manually on each machine.  I'll be sure to test your script in future installations.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now