Solved

Logon script default printer

Posted on 2009-05-15
8
1,885 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
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…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

732 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