Solved

Logon script default printer

Posted on 2009-05-15
8
1,871 Views
Last Modified: 2012-05-07
Hi,

I have a network of about 15 computers over two floors. I need to setup default printers for the employees, only problem is that depending on where the employees work (upstairs or downstairs) the printer will need to be different as there is a printer for each level.

I have attached the current logon script logon.bat
net use z: \\SIHC-SBS-1\SHARED FILES
 

@echo off

cls
 
 

Echo.

Echo.

Echo "Removing Printers"
 
 
 
 

 

rundll32 printui.dll,PrintUIEntry /dn /q /n \\Sihc-sbs-1\TOSHIBA_281_Mono
 
 

rundll32 printui.dll,PrintUIEntry /dn /q /n \\Sihc-sbs-1\TOSHIBA_281_colour
 
 

rundll32 printui.dll,PrintUIEntry /dn /q /n \\Sihc-sbs-1\TOSHIBA_351_colour
 
 

rundll32 printui.dll,PrintUIEntry /dn /q /n \\Sihc-sbs-1\TOSHIBA_351_Mono
 
 
 
 

Echo "Adding Printers"
 
 
 
 
 

 
 

rundll32 printui.dll,PrintUIEntry /in /q /n \\Sihc-sbs-1\TOSHIBA_281_Mono
 
 
 

rundll32 printui.dll,PrintUIEntry /in /q /n \\Sihc-sbs-1\TOSHIBA_281_colour
 
 
 

rundll32 printui.dll,PrintUIEntry /in /q /n \\Sihc-sbs-1\TOSHIBA_351_colour
 
 
 

rundll32 printui.dll,PrintUIEntry /in /q /n \\Sihc-sbs-1\TOSHIBA_351_Mono
 
 
 
 
 
 
 
 
 
 
 
 

net use z: "\\SIHC-SBS-1\Shared Files"

Open in new window

0
Comment
Question by:pabgm
8 Comments
 
LVL 9

Expert Comment

by:djpazza
ID: 24394391
Two tools are avialable from Microsoft for connecting to network printer and query domain groups.  Create a group in AD called e.g Upstairs and Downstairs and put the users in the right group.  Then download:

IfMember.exe

http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=07c2f6d7-815e-4fa0-9043-4e4635ccd417&displaylang=en

Con2prt.exe

http://download.microsoft.com/download/2/6/0/260afc88-2253-45f8-9781-546cff07edd9/zak.exe

Download to a share maybe where you are running the script from.
\\Sihc-sbs-1\netlogon\tools

Then you can have something like this in a bat file:

@ECHO OFF


@echo off
cls
 
 
Echo.
Echo.
Echo "Removing Printers"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /f

Echo "Adding Printers"
\\edisonuksrv01\netlogon\tools\ifmember.exe "Upstairs"
if errorlevel == 1 goto :Downstairs
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\Sihc-sbs-1\TOSHIBA_281_Mono"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\\Sihc-sbs-1\TOSHIBA_281_colour"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\Sihc-sbs-1\TOSHIBA_351_colour"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\\Sihc-sbs-1\TOSHIBA_351_Mono"
::Downstairs
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\Sihc-sbs-1\TOSHIBA_351_colour"
Echo "Setting Default Printer"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /cd "\\Sihc-sbs-1\TOSHIBA_351_Mono"
0
 
LVL 9

Accepted Solution

by:
djpazza earned 500 total points
ID: 24394401
Sorry typo try this:

@ECHO OFF


@echo off
cls
 
 
Echo.
Echo.
Echo "Removing Printers"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /f

Echo "Adding Printers"
\\Sihc-sbs-1\netlogon\tools\ifmember.exe "Upstairs"
if errorlevel == 1 goto :Downstairs
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\Sihc-sbs-1\TOSHIBA_281_Mono"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\\Sihc-sbs-1\TOSHIBA_281_colour"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\Sihc-sbs-1\TOSHIBA_351_colour"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\\Sihc-sbs-1\TOSHIBA_351_Mono"
::Downstairs
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /c "\Sihc-sbs-1\TOSHIBA_351_colour"
Echo "Setting Default Printer"
\\Sihc-sbs-1\netlogon\tools\con2prt.exe /cd "\\Sihc-sbs-1\TOSHIBA_351_Mono"
0
 

Author Comment

by:pabgm
ID: 24428056
Hi,

I have applied your code and it seems to be working yet i receive an error upon login:
\\Sihc-sbs-1\netlogon\tools\con2prt.exe is not a valid Win32 application.

Could this have something to do with it running in a 64bit enviment?
The server is SBS 2008
The clients are Windows XP Pro 32 bit.

Pablo

0
 
LVL 6

Expert Comment

by:astralcomputing
ID: 24428098
Use vb script

Set WshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\COMPUTERNAME\PRINTERNAME"
PrinterDriver = "DRIVER"
WshNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver

Add this line to make the printer the default

WshNetwork.SetDefaultPrinter "\\COMPUTERNAME\PRINTERNAME"

The "DRIVER" listed in line 3 is the one listed in the advanced tab on the print server system. "HP Laserjet 4" or "HP Laserjet 2050 PCL 6". I install all printers to a main server and install on all workstations this way.

You can use this to instantly install multiple printers. Save it as "whatever.vbs" and call it from your login script like this.

\\server\netlogon\installprinter.vbs



This works every single time and is instant.
0
Too many email signature changes to deal with?

Are you constantly being asked to update your organization's email signatures? Do they take up too much of your time? Wouldn't you love to be able to manage all signatures from one central location, easily design them and deploy them quickly to users. Well, you can!

 

Author Comment

by:pabgm
ID: 24428671
I just noticed that when the script is running you have to press ok every time the error appears ( about 5 times) in the background the CMD window starts off with "removing printers" and then it says access denied. is this something to do with access rights?
0
 

Author Comment

by:pabgm
ID: 24428673
note that my last comment is based on the original script, I have not tried your VB script yet.

Pablo.
0
 

Author Closing Comment

by:pabgm
ID: 31581865
Expert stopped answering my questions
0
 
LVL 1

Expert Comment

by:MigrationKing
ID: 32863891
Just to make someone else's life easier. Here is the Microsoft KB  article on GPO Network Printing using PushPrinterConnections.exe

http://support.microsoft.com/kb/973878http://support.microsoft.com/kb/973878
0

Featured Post

Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

Join & Write a Comment

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

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

11 Experts available now in Live!

Get 1:1 Help Now