PowerShell Ezine, Logon Scripts

Guy's Scripting Ezine No 16a: 
RUNDLL32 PRINTUI.DLL,PrintUIEntry

Contents of Guy's Scripting Ezine No 16a:
RUNDLL32 PRINTUI.DLL,PrintUIEntry  - Printer Scripts

I love co-operation.  This section illustrates the mutual help capability of the internet.

 

The initial challenge was to find a method of assigning a printer to a computer rather than a user.  What we wanted was a logon script that would create a printer no matter who logged on.

The basic command is:  RUNDLL32 PRINTUI.DLL,PrintUIEntry

Here are three useful commands kindly sent in by Pete Roper.

1) This installs printer quietly

rundll32 printui.dll,PrintUIEntry /in /q /n\\servername\printername

2) This deletes the networked printer from the machine being logged onto, and does so quietly.
rundll32 printui.dll,PrintUIEntry /dn /q /n\\servename\printername

3) This Sets the default printer

rundll32 printui.dll,PrintUIEntry /y /n\\servername\printername

ˆ

Randy Schuman kindly sent in this script.

Warning this script will need adjustment for your environment. For example edit the set pserver = CLTLBXPRN

Warning this script is viscous and will delete all your mapped printers.

 

@echo off

path=c:\util;%path%

set pserver=CLTLBXPRN

echo Remove All Network Printers.......

con2prt /f

echo Show All Available Printers From %pserver%.......

net view %pserver%

set /p pname= Enter Printer Name:

rundll32 printui.dll,PrintUIEntry /in /n\\%pserver%\%pname% /q

set pserver=

set pname=

exit

 

ˇ

 

Here is a little research that I undertook.

1) Check that  RUNDLL32 PRINTUI.DLL,PrintUIEntry /? works on your machine, I mention this as it only seems to work on Windows 2003, XP and Windows 2000 machines.

2) Amongst the zillions of switches it seemed that:  /in
- add network printer connection, was the most promising, however I could not get it to work.

3) /y /n Worked to set the default printer.  /y /n "Printer Name"

4) /ge /c \\machine also worked.

That is as far as I got, tantalizing and frustrating.

Here are my original sources of information:

 

Computer Training Software - Recommended Training VideosGuy Thomas recommends Computer Training Software

Their topics and material are ideal for getting you started with VBScript.  The videos are easy to follow and you can control the pace.  Try their free demo material and then see if you want to buy the full package. See more about VB Script Training CD.


 *


Google

WebComputerperformance.co.uk

GFi Events Manager

Guy Recommends: GFi EventsManager

Here is a solution to monitor, manage and archive thousands of events that are generated by devices across your entire network.  Get your free evaluation copy of GFI EventsManager.

 

Home Copyright © 1999-2008 Computer Performance LTD All rights reserved

Please report a broken link, or an error.