How do I set a Default Printer?

D

Dave

I have Win 2K Pro workstations with 5 printer connections
established via mandatory profile. How do I use group
policy to change the "default" printer when the user logs
on?

Thanks.
 
C

Chriss3

Hello, You can assing a script with GroupPolicy to do this, read the follow
article about how to assign scripts in group policy:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;322241#2

Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"
WshNetwork.SetDefaultPrinter "\\PrintServer1\Xerox300"


--
Regards,

Christoffer Andersson
No email replies please - reply in the newsgroup
If the information was help full, you can let me know at:
http://www.itsystem.se/employers.asp?ID=1
 
P

Paul McShane

This creates a default printer for every new user on the system, as long as
the admin user sets the default

'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.0
'
' NAME:
'
' AUTHOR: Paul McShane , Strathclyde Fire Brigade
' DATE : 22/10/2003
'
' COMMENT: 'Setup a printer as an admin. Run this script. A script will be
'created that sets up the same default printer for an Windows 2000 WS in the
'Default User Profile's Startup Folder.
'
'==========================================================================
'~~Script~~.
' SetupDefaultPrinter.vbs Free to read and distribute as long as above
information provided.



' This script only works when used with an account with local admin rights.
' Once a default printer has been setup in the profile of the administrative
' user, this script should be activated. It will create a script in the
' default user profile's startup folder. This script will setup the default
' printer established earlier for each user that logs on. After setting up
' their default printer, the script will auto delete itself from the user's
' startup folder.

' Extracts your current default printer information from the registry.

Set ws = WScript.CreateObject("WScript.Shell")
val = ws.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows\Device")
nCount = instr(val,",") -1
val = left(val,nCount)


' The following several lines define and create the "setup default
printer.vbs" file
' that will run from each new user's startmenu at first logon.

Dim fso, DefaultP
Set fso = CreateObject("Scripting.FileSystemObject")
Set DefaultP= fso.CreateTextFile("c:\documents and settings\default
user\start menu\programs\startup\set default printer.vbs", True)
valLine1 = "Set WshNetwork = CreateObject(" + chr(34) + "WScript.Network" +
chr(34) + ")"
DefaultP.WriteLine(valLine1)

' Defines the printer information obtained from the registry.
valLine2a = "Dim PrinterPath"
valLine2b = "strPrinterPath = " & chr(34) & val & chr(34)
valLine2c = "set WshNetwork = CreateObject(" & chr(34) & "Wscript.Network" &
chr(34) & ")"
valLine2d = "WshNetwork.AddWindowsPrinterConnection strPrinterPath"

DefaultP.WriteLine(valLine2a)
DefaultP.WriteLine(valLine2b)
DefaultP.WriteLine(valLine2c)
DefaultP.WriteLine(valLine2d)

' Tells user that printer has been setup.
valLine3 = "WScript.Echo " & chr(34) & "Default printer " & val & " has been
setup." & chr(34)
DefaultP.WriteLine(valLine3)
' ***line 40***
' Sets "setup default printer.vbs to delete itself from it's user's startup
folder and closes the file.

valLine4 = "Set WshShell = WScript.CreateObject(" & chr(34) &
"WScript.Shell" & chr(34) & ")"
valLine5 = "Set objWshSpecialFolders = WshShell.SpecialFolders"
valLine6 = "Dim fs, d, StrSetDef"
valLine7 = "strStartup = objWshSpecialFolders(" & chr(34) & "Startup" &
chr(34) & ")"
valLine8 = "StrSetdef = strstartup & " & chr(34) & "\set default
printer.vbs" & chr(34)
valLine9 = "Set fs = CreateObject(" & chr(34) & "Scripting.FileSystemObject"
& chr(34) & ")"
valLine10 = "set d = fs.GetFile(StrSetDef)"
valLine11 = "d.delete"

DefaultP.WriteLine(valLine4)
DefaultP.WriteLine(valLine5)
DefaultP.WriteLine(valLine6)
DefaultP.WriteLine(valLine7)
DefaultP.WriteLine(valLine8)
DefaultP.WriteLine(valLine9)
DefaultP.WriteLine(valLine10)
DefaultP.WriteLine(valLine11)

DefaultP.Close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top