Avatar of dee_nz
dee_nzFlag for New Zealand

asked on 

Logon script to remove printer drivers

Hi,
I'm having some trouble with getting a logon script to work properly. The script is to install a new printer on everyone’s PCs. I want the script to remove a network printer connection, stop & restart the printer spooler, remove the old printer drivers then re-connect the new network printer. I have created 2 batch files that are called from logon.vbs when users logon.
These commands work OK but only when the user logging in has admin rights?
Can someone please help with this?
High points because answer needed in a hurry!
Thanks in advance
-D

delete_abc_printers.bat
@echo off
REM delete old printer connection(s)
rundll32 printui.dll,PrintUIEntry /dn /n\\ABCdc01\ABCprt01 /q
REM stop & start print spooler
net stop spooler
net start spooler
REM delete old printer driver(s)
rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "PCL6 Driver for Universal Print" /h "Intel" /v "Windows 2000 or XP" /q
rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "RICOH Aficio 3045 RPCS" /h "Intel" /v "Windows 2000 or XP" /q
rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "RICOH Aficio MP C2000 RPCS" /h "Intel" /v "Windows 2000 or XP" /q
rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "RICOH Aficio MP C4500 RPCS" /h "Intel" /v "Windows 2000 or XP" /q

connect_abc_printers.bat
REM connect network printer
Start /wait rundll32 printui.dll,PrintUIEntry /in /n\\ABCDC01\ABCPRT01 /q
REM set default printer
rundll32 printui.dll,PrintUIEntry /y /n\\ABCDC01\ABCPRT01 /q

logon.vbs
' Connect ABC Printers
If IsMember("ABCUSER") then
      showstat("Connecting ABC Printers...Please Wait...")
' Remove old printers (temp)
      objShell.Run("%LOGONSERVER%\NETLOGON\delete_ABC_printers.bat"), 1, True

' Connect printers
objShell.Run("%LOGONSERVER%\NETLOGON\connect_ABC_printers.bat"), 1, True

End If
VB ScriptWindows Server 2003

Avatar of undefined
Last Comment
dee_nz
ASKER CERTIFIED SOLUTION
Avatar of Tony Massa
Tony Massa
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of dee_nz
dee_nz
Flag of New Zealand image

ASKER

Hi, Thanks for your help.
All domain users are "power users" this is what I cant get to work in our logon script.
Can you see what is wrong with it?
Thanks
-D
If IsMember("ABCUSER") Then
	showstat("Checking Printers...Please Wait...")
	' Remove Printer(s)
	WshNetwork.RemovePrinterConnection "\\acbdc01\abcprt01"
	' Re-connect Printer(s)
         WshNetwork.AddWindowsPrinterConnection "\\abcdc01\abcprt01"
	' Set default printer
	WshNetwork.SetDefaultPrinter "\\abcdc01\abcprt01"
End If

Open in new window

Avatar of Tony Massa
Tony Massa
Flag of United States of America image

Is there an event logged in either the SYSTEM or APPLICATION event logs?  What about the script itself?  Does it generate an error?
Avatar of dee_nz
dee_nz
Flag of New Zealand image

ASKER

Hi, Thanks for your comments. I gave up trying to get the logon script to work and went back to using printui.dll,PrintUIEntry commands in a batch file called from logon.vbs. In the end there were 2 things wrong with my original printer setup batch file.
1. the command syntax was wrong, I had some spaces missing and needed some speech marks " in the right places!
2. tmassa99 was correct users also did not have the correct permissions to change the printer drivers.
There are a few ways to fix this but in the end I created an Active Directory group called "PrinterInstall" that was a member of the local PCs administrators group and so had rights to run the printer batch file.
The logon script would only call printers.bat if the user was in the PrinterInstall group. Then I temporarily put users in the group, printers installed OK after a day or 2 then I removed them from the group.
Seemed to work OK ;)
Thanks for your help
-D
@echo off

:: Delete Network Printer(s) 
start /wait RunDll32 printui.dll,PrintUIEntry /dn /q /n "\\abcdc01\abcprt01"

:: Stop & Start Print Spooler 
start /wait net stop spooler
start /wait net start spooler

:: Delete Old Printer Driver(s) 
start /wait rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "PCL6 Driver for Universal Print" /h "Intel" /v "Windows 2000 or XP" /q
start /wait rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "RICOH Aficio 3045 RPCS" /h "Intel" /v "Windows 2000 or XP" /q
start /wait rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "RICOH Aficio MP C2000 RPCS" /h "Intel" /v "Windows 2000 or XP" /q
start /wait rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "RICOH Aficio MP C4500 RPCS" /h "Intel" /v "Windows 2000 or XP" /q
start /wait rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "HP LaserJet 4050 Series PCL" /h "Intel" /v "Windows 2000 or XP" /q
start /wait rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "RICOH Aficio MP 5001 PCL 6" /h "Intel" /v "Windows 2000 or XP" /q
start /wait rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "RICOH Aficio MP C5000 PCL 6" /h "Intel" /v "Windows 2000 or XP" /q
start /wait rundll32 printui.dll,PrintUIEntry /dd /c\\%ComputerName% /m "RICOH Aficio 3224C RPCS" /h "Intel" /v "Windows 2000 or XP" /q

:: Connect Printer(s) 
start /wait RunDll32 printui.dll,PrintUIEntry /in /q /n "\\abcdc01\abcprt01"

:: Set default printer 
start /wait rundll32 printui.dll,PrintUIEntry /y /q /n "\\abcdc01\abcprt01"

Open in new window

Avatar of dee_nz
dee_nz
Flag of New Zealand image

ASKER

Here is the logon.vbs printer section

' **********************************************************
' ***        Connect Network Printers                       ***
' **********************************************************
 If IsMember("InstallABCPrinters") Then
      showstat("Checking ABC Printers...Please Wait...")
      Set objShell = WScript.CreateObject("WScript.Shell")
      objShell.Run("%LOGONSERVER%\NETLOGON\abc_printers.bat"), 1, True
 End If
Avatar of dee_nz
dee_nz
Flag of New Zealand image

ASKER

Although I still couldnt get the VB script to work this info led me to find the solution because users did not have the correct rights to change printers. Thanks for the quick reply too ;)
-D
Windows Server 2003
Windows Server 2003

Windows Server 2003 was based on Windows XP and was released in four editions: Web, Standard, Enterprise and Datacenter. It also had derivative versions for clusters, storage and Microsoft’s Small Business Server. Important upgrades included integrating Internet Information Services (IIS), improvements to Active Directory (AD) and Group Policy (GP), and the migration to Automated System Recovery (ASR).

129K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo