Solved

Logon script default printer

Posted on 2009-05-15
8
1,883 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

749 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