My boss made a new printer script and it works locally but when we tries to deploy it as a startup script it fails to run at all. Its been added as startup script to the relevant OU but no matter what we try it doesn't work. Any ideas?

Printers are a per user setting (unless they are a locally attached printer). Why not use my VBScript and run it at logon?
Richard is is similar to this when you open up the script?
rundll32 printui.dll,PrintUIEntry /ga /n"\\print\HPLJ2300 BS1"
We use scripts like that in a batch file run once on the local computer to set the printers for all users on that PC. I haven't tried it but I don't see any reason why it wouldn't work - although perhaps it's a rights issue if the user isn't allowed to add printers. We run it as an administrator, pretty sure it won't work here as a normal user.
As Ric says I think running one as a VBscript somehow would work, done that in the past for other items but not entirely sure what script you'd need in this instance.
Here's the vbs script that he's written
Its been set as a startup script in the computer configuration. I have also tried to run it when a user logs in but to no avail.Code:Option Explicit Dim objNetwork, strLocal, strUNCPrinter1, strUNCPrinter2 strUNCPrinter1 = "\\Server1d\RICOHMA" Set objNetwork = CreateObject("WScript.Network") objNetwork.AddWindowsPrinterConnection strUNCPrinter1 objNetwork.SetDefaultPrinter "\\Server1d\RICOHMA" WScript.Quit
Printer scripts do not run as a Computer startup script. You need to assign the script to the USER startup script
ie USER CONFIGURATION\WINDOWS SETTINGS\SCRIPTS (LOGON/LOGOFF)\LOGON
You could edit your script so that it looks at the machine name and decide what printer map. Here's mine
Code:' automated printer redirection setup for users as script fails for machine startup ' if the printer is OFF then the script will fail ' what if the printer is not in the list of installed printers?? Option Explicit DIM RegEntry, ComputerName RegEntry="HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName" ComputerName = ReadRegValue(RegEntry) 'if InStr(1,ucase(ComputerName),"Part or whole machine name",vbTextCompare) > 0 then call SetPrinter("\\Server\Printershare") if InStr(1,ucase(ComputerName),"Admin",vbTextCompare) > 0 then call setPrinter("\\Server\AdminPrinter") ' keep adding lines for each location – modify just the sections in quotes as needed wscript.quit ' *** This subroutine installs and sets the default printer Sub SetPrinter(ByVal PrinterPath) On Error Resume Next DIM WshNetwork Set WshNetwork = CreateObject("WScript.Network") WshNetwork.AddWindowsPrinterConnection(PrinterPath) WshNetwork.SetDefaultPrinter Printerpath end sub ' **** This function returns the data in the registry value Function ReadRegValue(ByVal RegValue) DIM WSHShell Set WSHShell = WScript.CreateObject("WScript.Shell") ReadRegValue="" On Error Resume Next ReadRegValue= WSHShell.RegRead(RegValue) End Function
This may not be sufficient. If the user does not have enough access to the machine to install drivers, the printer will not work. You can get round this by running the printer script at machine start-up though and pre loading the drivers.Printer scripts do not run as a Computer startup script. You need to assign the script to the USER startup script
If in doubt, I suggest you run the printer script both at computer start-up and user login. Unless you're overly concerned about machine start-up times of course.
I have start-up batch file scripts setup so that the different groups in Active Directory install different printers at start-up by running the correct script for the room grouping. I do this by using the rundll32 printui.dll,PrintUIEntry command and they look a bit like this.
The first 2 commands delete any existing copies of the printers if already installed the second 2 install the correct printers, network path and drivers. The last one sets the default printer name for windows to use.Code:rundll32 printui.dll,PrintUIEntry /dl /n "HP Color LaserJet 3700 in D26" /q rundll32 printui.dll,PrintUIEntry /dl /n "HP B&W LaserJet 3700 in D26" /q rundll32 printui.dll,PrintUIEntry /u /if /b "HP Color LaserJet 3700 in D26" /f "\\jogdom.local\NETLOGON\InstallPrinters\Drivers\HP LJ 3700n\hpc3700c.inf" /r "\\JOGSERV01\hp3700n-002$" /m "HP Color LaserJet 3700 PCL 6" /q rundll32 printui.dll,PrintUIEntry /u /if /b "HP B&W LaserJet 3700 in D26" /f "\\jogdom.local\NETLOGON\InstallPrinters\Drivers\HP LJ 24x0\hpc24x0c.INF" /r "\\JOGSERV01\hp3700n-002BW$" /m "HP LaserJet 2420 PCL 6" /q rundll32 printui.dll,PrintUIEntry /y /n "HP B&W LaserJet 3700 in D26" /q
Don’t know if that helps as you are using a different type of scripting but for plain old *.BAT scripts this works really well.
![]()
I could be wrong here but I do not think that logon/startup scripts are run with the users credentials - I think they are run by the System accountOriginally Posted by Geoff
I can't tweak the script as its my bosses and he doesn't like me touching things he does and i'm not in work now till thursday but i'll have another look when i'm back
I think it might be because the drivers for the printer are not installed on the pc’s you’re deploying the VB scrip to, so it simply doesn’t install the printer and ignores it.Originally Posted by richard
You also will probably need to defiantly run them as start-up scripts because start-up scripts are run with Admin privileges and logon scripts are run with the logging-on-user privileges.
p.s. If you try out my *.BAT scripts way of doing it, be warned that parts of the script are case sensitive as I found out the long way after days experimenting. I think its because the driver file printer name/description must be an exact match to find the driver in the *.INF file!!!!
![]()
Yes the login scripts are run with elevated credentials, however if you've altered any of the driver installation group policy settings it'll break. Thus the need to have the script run during computer start-up (as it uses the computers domain account, which also has system level privileges to the local machine).Originally Posted by tosh74
Pretty sure that's not true.
machine startup scripts run in the security context of the machine so can do pretty much anything to the machine but may not have access to network resources (if you need a machine script to access files on a server then give domain computers read access to the relevant files)
user scripts run in the security context of the user - they have no special rights.
local printers need to be able to install drivers on the machine so can't be installed as a normal user. network printers don't need this - anyone can add a network printer.
If you're scripting it then using the rundll32 printui.dll,PrintUIEntry type command is effectively installing a local printer - it could run as a machine startup script but won't run as a user logon script.
Scripts running using the vbscript WshNetwork.AddWindowsPrinterConnection type command add network printers and can be run by ordinary users - that's why it's ideal for a login script (but useless as a machine startup script because you'll end up mapping a printer which is only available for the computer account!)
If you've written a vbscript login or startup script then use a debugger to step through it to see what it's actually doing. Any version of Visual Studio will do this or you can download the Microsoft Script Debugger (google it - the URL is too long!) You then run the script with //x at the end and it runs through the debugger.
There are currently 1 users browsing this thread. (0 members and 1 guests)