Print script to set default not working (Win2003Server SBE)
I'm running Win2003 SBE Server SP2. Got a login script that execute for every users to set network printers, but the default printer setting (/y option)doesn't work.
rundll32 printui.dll,PrintUIEntry /in /u /l\\IP10PP17.wds.local /n\\IP10PP17.wds.local\LaserJet1522 /q
rundll32 printui.dll,PrintUIEntry /y /n\\IP10PP17.wds.local\LaserJet1522
I keep getting error "Operation could not be completed."
Help.
Re: Print script to set default not working (Win2003Server SBE)
Re: Print script to set default not working (Win2003Server SBE)
Putting a simple batch file in place to run on every user’s Logon will help you solve this issue, as this helped at my work place:
- Create a batch file by going to My Computer, choose the root file path of the hard drive (usually C:), right-click on some empty space and select New Text Document.
- Next, open your new text document and type in one of the following lines:
- If you have a networked printer, type rundll32 printui.dll,PrintUIEntry /y /n\\%printername%
- If you have a local printer, type rundll32 printui.dll,PrintUIEntry /y /n”%localprintername%
- Choose Save As in Notepad and change the type of file from Text (.txt) to 'All Files'. Name it something like printer.bat (the printer part is not important, the .bat part is) and save it to the C: drive.
- Go to Start -> Run and type gpedit.msc to launch the Management Console.
- Under User Configuration -> Windows Settings, you will find Scripts (Logon / Logoff). Double-click on Logon in the main window (to the right) and choose Add to add a new script.
- Browse for your batch file (should be on C:). You dont need any additional parameters. At this point, every user that logs in will have their default printer reset to the one you want.
Best of Luck.
Re: Print script to set default not working (Win2003Server SBE)
I do not have problem installing the printers. I already have the batch file in the server which assigns the network drives and printers, and they all work fine.
The problem I'm having is using the "/y" option to set default. Only when I used the option "/y" to set the default printer is where I get that error, otherwise, users can print from any workstation just fine.
It acts like the "/y" option does not exist, although "/?" option shows it.
Re: Print script to set default not working (Win2003Server SBE)
I had similar issues with trying to utilize rundll32 to adjust printer settings on workstations. Also, I had issues with machines not always applying the settings specified in the commands. Instead I used a VB script to set the default printer. The script is written so I can control which computers set which printer as default based on group membership regardless of the user who logs on. I have this implemented in several school districts I support as they have computer labs where they want a specific default printer applied, independent of the user logged on. The same logic could be applied for different "departments" who should be defaulted to a particular printer.
The only issue; I have not tested this script on network printers connected by mapping, only network printers locally installed on the computers (printing thru TCP/IP port).
If interested in trying this other method, I will post up some samples of the code used and some instructions for implementing.
Re: Print script to set default not working (Win2003Server SBE)
@ itchibahn
Oh...so I got your problem now. Has never come across "/y" option problem. But will try to figure out some solution for this.
Quote:
Originally Posted by
DigitalPrimate
If interested in trying this other method, I will post up some samples of the code used and some instructions for implementing.
I am curious to know that other method :dribble:
Re: Print script to set default not working (Win2003Server SBE)
- Solomon
Here's how we addressed it:
First, this VB script is based on the printer name so it will have to be identical across all computers. In theory, I guess this should work using a mapped network printer as that name should always remain the same as well. However, we only tested it on locally installed network attached printers (HP Laserjet with JetDirect cards, etc). We clone the workstations and add the printers ahead of time, so it was no big deal to implement this. Plus, users do not have admin rights so the printer names will not get changed.
1) Install the required printer(s) on the workstations and name them with the same names across workstations. I guess this could be done using a script to map them on logon.
2) Create an Active Directory Security Group for each targeted printer or department. Add all workstations that should default to the specific printer to the security group. (This part has only been tested in Active Directory based networks however the script could be adapted to bypass this step. You could then simply control default printers by individual user logon script.)
3) Create a .VBS script containing the following code in a network-accessible location. We used the AD Netlogon folder. Copy between the dotted lines, don't include the dotted lines. Change the parts in CAPS to match your network.
----------------------------
'Script Begins Here
Dim objNetwork, objComputer, strDomain, strComputerName
strDomain = "YOURDOMAINNAME"
Set objNetwork = CreateObject("Wscript.Network")
strComputerName = objNetwork.ComputerName
Set objComputer = GetObject("WinNT://" & strDomain & "/" & strComputerName & ",computer")
If IsGroupMember(strDomain, "YOURGROUPNAME") Then
objNetwork.SetDefaultPrinter "YOURPRINTERNAME"
End If
Set objNetwork = Nothing
Set objComputer = Nothing
Wscript.Quit
Function IsGroupMember(strDomain, strGroup)
Dim objGroup
Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")
If objGroup.IsMember(objComputer.ADsPath & "$") Then
IsGroupMember = True
Else
IsGroupMember = False
End If
Set objGroup = Nothing
End Function
-------------------------------------
4) Add the following line to your users' logon scripts:
cscript \\YOURSERVER\NETLOGON\SCRIPTNAME.vbs
=========================================
That's it. The schools we implemented this in had multiple computer labs, so we had one security group called "Lab1" with all the computers in Lab1 as members and one security group called "Lab2" with all the computers in Lab2 as members. Then we had two scripts, one called lab1.vbs and one called lab2.vbs. Finally, we added each script on its own line to all logon scripts:
cscript \\OURSERVER\NETLOGON\LAB1.vbs
cscript \\OURSERVER\NETLOGON\LAB2.vbs
(The scripts could be combined if desired, but we kept them seperate for ease of upkeep and understanding for the schools' IT departments to continue to modify.)
Now, when any user logs into a computer in a lab, it automatically sets the correct default printer for that lab. And if the user logs into a workstation outside of the labs (like classroom workstations) the script changes nothing because the computer is not a member of the proper security groups. Obviously this is very beneficial when a fresh user logs onto a PC for the first time as no intervention is required to set the correct default printer. This had not added any noticeable time to execution of the logon script either.
By the way, the script content was found elsewhere on the Internet so kudos to the original author. We just implemented it and tweaked it a little bit for our own use.
HTH :ohyeah:
Re: Print script to set default not working (Win2003Server SBE)
Got the below to work. Thanks all.
' Set default printer
Option Explicit
Dim objPrinter
Set objPrinter = CreateObject("WScript.Network")
objPrinter.SetDefaultPrinter "\\printer_server\printer_name"
Re: Print script to set default not working (Win2003Server SBE)
I thank you both for posting the solution here which will be helpful for other members with similar problems.
Well, that is all happy endings...and I like that :ohyeah: