Windows Thread, Default Printer Batch File in Technical; Hello,
I would like a batch file to rung at system startup/userlogon to set the default printer for all users. ...
11th April 2008, 02:50 PM #1
- Rep Power
Default Printer Batch File
I would like a batch file to rung at system startup/userlogon to set the default printer for all users. I set it as administator but it then doesn't change for users. I can't really put it in the logon.bat as its only needed for one room and the other rooms have a different default.
IDG Tech News
11th April 2008, 03:00 PM #2
We tend to do ours with a batchfile that runs at user login using con2prt to map..
11th April 2008, 03:42 PM #3
How about a .vbs script?
Set net = WScript.CreateObject("wscript.network")
I got fed up of having different scripts for each OU so made a new one from some examples on the web that maps a few general printers, checks the OU of the Computer then maps any specific ones after that. It also looks to see if the current user is a member of a colour printer group, if so they get it mapped automatically Hopefully should be rolling that out in the summer on the top level policy so when staff move offices their default printer changes as well.
11th April 2008, 04:26 PM #4
You have to do this as a user script because (as you've found!) things like default printer are user specific.
Originally Posted by karldenton
There's a million (!) ways to do it but basically, you need to determine which room you're in and then set the default appropriately. Assuming you put computers into specific OUs based on rooms then your script just needs to find the OU and then map accordingly - there are loads of examples here about how to do this.
The nice, new, sexy way to do this is with group policy preferences - we're still rolling out the extension to our workstations so I haven't yet tried this but I think it has the potential to make life much easier :-)
14th April 2008, 11:03 AM #5
- Rep Power
Thanks for the replys.
I've got a batch file, which works:
' Option Explicit
Dim objNetwork, strUNCPrinter, strUNCPrinter1, strUNCPrinter2
strUNCPrinter = "\\2003server\libraryb1430"
Set objNetwork = CreateObject("WScript.Network")
Set WSHPrinters = objNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
'objNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
'end delete existing printers
Is it possible to asign this to a computer OU rather than user?
14th April 2008, 12:39 PM #6
We used to have a script that had that loop counter in there but it never seemed to work right, if you want to delete all network printers before mapping try this...
'Deletes old network printers
On error Resume Next
Dim cNetCommands, vPrinterName, vPrinterPath
Set cNetCommands = WScript.CreateObject("WScript.Network")
Set vPrinterPath = cNetCommands.EnumPrinterConnections
For Each vPrinterName in vPrinterPath
Seems to work a lot more reliably for me
As for assigning to computers this link may prove useful
Logon Script Example Assign Printer - RUNDLL32 PRINTUI.DLL
Last edited by gshaw; 14th April 2008 at 12:42 PM.
14th April 2008, 01:20 PM #7
As others have basically said... there's no point re-inventing the wheel. Check out Scripting Printer Addition Based on Location - EduGeek.net Wiki and if others have anything to add please do add it to the wiki.
14th April 2008, 01:38 PM #8
- Rep Power
OK guys, thanks foe the help.
Like i said, i have this vbs file which works fine when you run it as any user. I have put it in a shared location on the network. In gp, user config, windows settings, scripts, logon i have put a path to a logon script, which is :
The script executes:
"cscript.exe \\2003server\SharedArea\ITTechnician\LibraryPrinte r\libdefault.vbs".
Done a gpupdate /force but still does't seem to work.
14th April 2008, 01:49 PM #9
Hmm, I should probably add my enhancements
Originally Posted by Ric_
14th April 2008, 01:50 PM #10
- Rep Power
we put a shortcut in all users > startup from a shair on the server that let students and staff have read access, works a treat
14th April 2008, 02:01 PM #11
karl: It appears that you have a vbscript allready and not a batch script.
gshaw: Doesn't your script remove ALL printers and not just network ones?
14th April 2008, 02:47 PM #12
Instead of having the batch file, just call the VBScript directly from the GPO.
Originally Posted by karldenton
23rd March 2010, 03:18 PM #13
We got printers installed on each machine all printing to the same 2 printers one colour and one mono
i wanna change the default with out going to each machine i can do it locally or creating a startup bat file using defprint but i wanna do it like this because im lazy lol
defprint \\suite04 /d "IP_192.168.1.188"
defprint \\suite05 /d "IP_192.168.1.188"
but i cant seem to find the right switches any ideas? i dont really want to use a script or something that runs at starts up but ran once and thats it.
23rd March 2010, 06:16 PM #14
The below works fine for me. If I'm honest a friend sent it to me... But I'm not! It's MINE! ALL MY OWN WORK!!!!
This also works to apply any users settings to a computer regardless of who logs into it.
For script to run on computers use Loopback processing in Merge Mode
That would allow you to apply a script to a Computer Account but using the User section of the policy.
To set it up what you need to do is:
1. Create a Group Policy with the Loopback Policy enabled:
Computer Configuration --> Administrative Templates --> System --> Group Policy
User Group Policy loopback processing mode: Enabled & Merge
2. Create a Group Policy attached to the OU containing the computer account with the script in the:
User Configuration --> Windows Settings --> Scripts Logon --> printers.vbs.
The Replace operation stops all other User based policies applying there and only uses those that would apply to the Computer OU.
The Merge operation uses the normal User based policies as well, but any policies set on the Computer OU take precedence.
Script for automated mapping of printer according to room number:
rem ** Next line must not be deleted **
Set WshNetwork = CreateObject("WScript.Network")
rem ** This will delete existing printers **
On Error Resume Next
Set oPrinters = WshNetwork.EnumPrinterConnections
For i = 1 to oPrinters.Count - 1 Step 2
rem ** Setup new printer connection **
rem ** Setup default printer **
By martyn in forum Scripts
Last Post: 20th February 2008, 05:29 PM
By meastaugh1 in forum Windows
Last Post: 17th January 2008, 09:02 PM
By MrLudwig in forum Windows
Last Post: 8th December 2007, 03:40 AM
By macca in forum Windows
Last Post: 3rd May 2007, 10:20 AM
By beeswax in forum Scripts
Last Post: 3rd March 2006, 08:48 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)