Solved

Logon script default printer

Posted on 2009-05-15
8
1,878 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

I work for a company that primarily works with small businesses as their outsourced IT vendor. As such the majority of these customers utilize some version of Small Business Server. Due to the economics of running a small business, many of these cus…
If you are a user of the discontinued Microsoft Office Accounting 2008 (MSOA) and have to move to a new computer running Windows 8, you will be unhappy to discover that it won't install.  In particular, Microsoft SQL Server 2005 Express Edition (SSE…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
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…

831 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