Solved

Logon script default printer

Posted on 2009-05-15
8
1,879 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

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 article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

840 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