I am creating a batch file to add printers to users in our domain and am hitting a slight snag in the lines.

Here is the batch file for one of our user profiles:

-------------------------------------------------------------------------
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-MAINT-2035n"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-ACCT-HP9000uni"
rundll32 printui.dll,PrintUIEntry /y /in /n "\\PRNTSVR01\P1-AEDE-5500pcl"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-LAB-PANA8060pcl"
-------------------------------------------------------------------------

From what I've read about the switches, '/y' should set that printer to the default printer. Though when I go back to look at the final results, all printers in the file have been added and the selected printer was not set to the default printer.

Any idea as to how or to fix this or why it did not work? Any answers would be appreciated.

Unless I am mistaken you have to install the printer first then set it as the default printer.

I would assume you are using Window XP since not much information has been given on the setup. If you want the particular printer to be default simply use the mouse and point to the printer icon and right click on the mouse than select the printer as default.

Well, we are looking at having this done through group policy and we found that the batch file shown was an easier way for us to control who gets what printer. Also if the printer has to be installed first before that '/y' switch will work, then what would we be able to use to change that?

The computers for users are primarily Windows XP and we are currently switching to Windows 7 as we replace older units. But this batch file works on both OS's all it requires is the correct driver for that printer to be available.

Sorry, I seem to found the answer to my primary question...

Incorrect Batch File:
-------------------------------------------------------------------------
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-MAINT-2035n"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-ACCT-HP9000uni"
rundll32 printui.dll,PrintUIEntry /y /in /n "\\PRNTSVR01\P1-AEDE-5500pcl"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-LAB-PANA8060pcl"
-------------------------------------------------------------------------

Correct Batch File
-------------------------------------------------------------------------
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-MAINT-2035n"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-ACCT-HP9000uni"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-AEDE-5500pcl"
rundll32 printui.dll,PrintUIEntry /y /n "\\PRNTSVR01\P1-AEDE-5500pcl"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-LAB-PANA8060pcl"
-------------------------------------------------------------------------

This actually set the required printer to the default printer. So it seems you have to install the printer first then run a new command to make the desired printer become the default. My credits to 'rch1231', you mentioned about installing the printer first. That got me thinking on the file and so i found the answer within a few minutes. Bad news that Microsoft's Help Command doesn't make that disclaimer. Nor do any of the webpages I found.

Sorry, I seem to found the answer to my primary question...

Incorrect Batch File:
-------------------------------------------------------------------------
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-MAINT-2035n"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-ACCT-HP9000uni"
rundll32 printui.dll,PrintUIEntry /y /in /n "\\PRNTSVR01\P1-AEDE-5500pcl"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-LAB-PANA8060pcl"
-------------------------------------------------------------------------

Correct Batch File
-------------------------------------------------------------------------
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-MAINT-2035n"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-ACCT-HP9000uni"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-AEDE-5500pcl"
rundll32 printui.dll,PrintUIEntry /y /n "\\PRNTSVR01\P1-AEDE-5500pcl"
rundll32 printui.dll,PrintUIEntry /in /n "\\PRNTSVR01\P1-LAB-PANA8060pcl"
-------------------------------------------------------------------------

This actually set the required printer to the default printer. So it seems you have to install the printer first then run a new command to make the desired printer become the default. My credits to 'rch1231', you mentioned about installing the printer first. That got me thinking on the file and so i found the answer within a few minutes. Bad news that Microsoft's Help Command doesn't make that disclaimer. Nor do any of the webpages I found.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.