Jump to content

not setting default printer script


dubsdj

Recommended Posts

Hi there

I wrote a script recently that looks like this:

Set WshNetwork = WScript.CreateObject("WScript.Network")

PrinterPath = "\\server\printer1"

PrinterPath2 = "\\server\printer2"

PrinterPath3 = "\\server\printer3"

WshNetwork.AddWindowsPrinterConnection PrinterPath

WshNetwork.AddWindowsPrinterConnection PrinterPath2

WshNetwork.AddWindowsPrinterConnection PrinterPath3

WshNetwork.SetDefaultPrinter PrinterPath3

Anyway I execute the script via a logon.bat which is set in Group Policy Computer Startup

The user logs in and the printers are added fine but it does not set the default printer to the one I specified????? It's really strange because if I run it from my desktop (I'm an Administrator) it adds the printers and then a second later the default printer changes to the one I want so It seems like the script does work for me but just not for the clients when logging in... I don't think its a permissions thing as I allow users to add and remove printers if they want because they are all removed when the log off anyway..

Does it have anything to do with the Current_user ??

The users have roaming profiles but I didn't think that would matter as its run at computer startup and should work anyway... But for some reason it ain't working properly..

Also could it have anything to do with it being in the Computer startup scripts and not in the user logon? Thing is that it needs to be applied to the computers as different areas have different scripts mapping different printers..

Any ideas??

Like I said the script adds the printers for the user fine.... just seems to not change the default....

Anyway thanks for any advice in advance.

Link to comment
Share on other sites


You need to run the portion of the script that sets the default printer using User Logon not Computer Startup as this settings is configured per user in the HKCU portion of the registry. You can try creating two scripts one that installs the printers and the other that sets the default printer.

Edited by FrankE9999
Link to comment
Share on other sites

At work we are currently upgrading ALL the company's computers and I took a glance at the script to see what they were doing. Though I don't have the exact thing in front of me, I remembered bits and pieces of it and found something through Google that is similar and might help you (listed below since there are multiple codes on that page).

Pete Roper sent in printui.dll commands
The key technique is rundll32 printui.dll,PrintUIEntry.

1) This installs printer quietly

rundll32 printui.dll,PrintUIEntry /in /q /n\\servername\printername

2) This deletes the networked printer from the machine being logged onto, and does so quietly.
rundll32 printui.dll,PrintUIEntry /dn /q /n\\servename\printername

3) This Sets the default printer
rundll32 printui.dll,PrintUIEntry /y /n\\servername\printername

This looks very, very similar to the code at work, and at work whenever I re-run the code and choose a different default printer, the default printer changes like it's supposed to.

Hope that helps!

Link to comment
Share on other sites

i know this isnt answering your question in the way you wanted but have you got R2? it has a great print management console.

Either that or use good ol con2prt.exe from the zero admin resource kit, you can map printers, set defaults ect.

just a suggestion :)

Link to comment
Share on other sites

You need to run the portion of the script that sets the default printer using User Logon not Computer Startup as this settings is configured per user in the HKCU portion of the registry. You can try creating two scripts one that installs the printers and the other that sets the default printer.

Ok so are u saying that in the policy for the OU containing the computers in the specific area I go to the user logon part of the group policy instead of the computer startup part?

Many thanks to everybody for their help with this issue I'm having, I really appreciate it.

Link to comment
Share on other sites

Well I had no luck with all of the things above.

Here's how i fixed my problem

1. I created a batch file and installed the printers

2. I then added the Stop and Start print services into the batch file after I had installed the printers.

3. I put the batch file in the group policy computer startup

4. I then created another batch file which runs the con2prt.exe and sets the printer i wanted as a default.

5. I created a shortcut to the con2prt batch file and put it in the all users startup folder on the machines where I wanted to default printer to be set.

I hate printers.... For something so simple It's been a real nightmare to achieve.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...