![]() |
|
|
|||||||
| Petri.co.il is happy to award auglan the title of Most Valuable Member !!! |
| Register | Calendar |
Search |
Today's Posts |
Mark Forums Read |
| Notices |
|
|
Edit users' printer settingsthis thread has 8 replies and has been viewed 3611 times
|
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||||||
|
||||||||
|
We need to redirect users in our NT4 domain so that they look to a new printer server for their existing network printers. The printer name will remain the same but the server name will change. It would be nice to be able to edit their roaming profiles, if possible. Each user may have several printers on 2 or 3 servers. I see the problem will be to lookup \\server\printer and change it to \\new_server\printer, but I don't know where and what to edit.
|
|
#2
|
||||||||||
|
||||||||||
|
Hi there
EDIT: Of course there is an easy way - i wasn't thinking. * Enumerate all the printers * Add the new printer by swapping the server name in the UNC * Delete the old printer Now i dont know how proficient you are with VB script but using these examples should get you to the point where you want to be: http://www.microsoft.com/technet/scr...t/default.mspx
__________________
Server 2000 MCP Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com ** Remember to give credit where credit is due and leave reputation points Last edited by tonyyeb; 15th November 2006 at 15:53.. Reason: Being slow in the brain |
|
#3
|
||||||||||
|
||||||||||
|
I once wrote this script, hopefully it helps you out.
I'ms sure others can write it much more better, however this works for me a few years ago. Code:
'==========================================================================
'
'' NAME: Remove and add printerconnecton
'
' AUTHOR: Marcel
' DATE : 6-7-2003
'
' COMMENT: This printer checks whatever the default printer is. Also he will remove and install the new printers
'==========================================================================
Option Explicit
'Variable Declaratie
Dim oPrinter,DefPrinter,oReg,DefLocal,GetSize,DefNetwork,x,Defnew
Set oReg = CreateObject ("wscript.shell")
set oPrinter = CreateObject ("Wscript.network")
Read Default printer
DefPrinter = Oreg.RegRead ("HKCU\Software\microsoft\windows NT\Currentversion\Windows\Device")
If Left (DefPrinter,11) = "\\Servedc01" Then WScript.Quit (0)
If Left (DefPrinter ,2) = "\\" Then
'Check if the default printer start with \\
if Left (DefPrinter,8) = "\\AEDPCD" Then
'if the default printer begins eith \\AEDPCD
WScript.Echo "Local shared printer used"
WScript.Echo "Adding ICT printer temporary"
On Error Resume Next
oPrinter.SetDefaultPrinter "\\Serveps06\Servep11"
If Err <> 0 Then
On Error Resume next
oPrinter.SetDefaultPrinter "\\Servedc01\Servep11"
If Err = 0 Then
SetDefnetwork
SetNetwork
WScript.Quit (0)
Else
oPrinter.AddWindowsPrinterConnection "\\Serveps06\Servep11"
oprinter.SetDefaultPrinter "\\Serveps06\Servep11"
End If
End If
WScript.Echo "using temporary ICT printer"
DeleteAll
AddAll
SetDefnetwork
SetNetwork
End if
If Left (DefPrinter,11) = "\\Serveps06" Then
'If the default printer begins with \\Serveps06 do
WScript.Echo "old printer are defiend"
WScript.Echo DefPrinter
DeleteAll
AddAll
SetDefnetwork
SetNetwork
End If
Else
If Right (DefPrinter,5) = "LPT1:" Then
'IF LPT1: See the start from the default printer
WScript.Echo "Local Printer installed."
DefLocal=DefPrinter
DefPrinter = ""
oPrinter.AddWindowsPrinterConnection "\\Serveps06\Servep11"
oPrinter.SetDefaultPrinter "\\Serveps06\Servep11"
WScript.Echo "Default printer temporary set to ICT printer"
DeleteAll
AddAll
Setlocal
End If
end If
Sub Setlocal
'Set Default printer back to Local printer
If DefLocal <> "" Then
oReg.RegWrite "HKCU\Software\microsoft\windows NT\Currentversion\Windows\Device" , DefLocal, "REG_SZ"
WScript.Echo "Default been set on Local Port"
end If
End Sub
Sub SetDefnetwork
'find what the printer share name is,without the servername
'Also change the servername
if DefPrinter <> "" Then
GetSize = InStr(defprinter, ",")-1
DefNetwork = left (DefPrinter, getsize)
DefNew = Replace (defnetwork,"\\Serveps06\","\\Servedc01\") 'Change servername over here
End If
End Sub
Sub SetNetwork
'Set new default networkprinter
WScript.Echo "Set default network printer"
If DefNetwork <> "" Then
oPrinter.SetDefaultPrinter Defnew 'printer goed zetten
End If
End Sub
Sub DeleteAll
'Delete Al printers
On Error Resume Next
WScript.Echo "deleting Printers"
oPrinter.RemovePrinterConnection "\\Serveps06\Servep01"
oPrinter.RemovePrinterConnection "\\Serveps06\Servep02"
oPrinter.RemovePrinterConnection "\\Serveps06\Servep03"
oPrinter.RemovePrinterConnection "\\Serveps06\Servep04"
oPrinter.RemovePrinterConnection "\\Serveps06\Servep05"
oPrinter.RemovePrinterConnection "\\Serveps06\Servep06"
oPrinter.RemovePrinterConnection "\\Serveps06\Servep07"
oPrinter.RemovePrinterConnection "\\Serveps06\Servep11"
oPrinter.RemovePrinterConnection "\\Serveps06\Servep12"
oPrinter.RemovePrinterConnection "\\Serveps06\Colonnadeduhafp01"
oPrinter.RemovePrinterConnection "\\Serveps06\aedexp01"
oPrinter.RemovePrinterConnection "\\Serveps06\Woonenergiep01"
End Sub
Sub AddAll
'Add all Printers
WScript.Echo "Adding Printers"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Servep01"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Servep02"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Servep03"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Servep04"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Servep05"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Servep06"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Servep07"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Servep11"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Servep12"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Colonnadeduhafp01"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\aedexp01"
oPrinter.AddWindowsPrinterConnection "\\Servedc01\Woonenergiep01"
end Sub
__________________
Marcel Netherlands http://www.phetios.com http://blog.nessus.nl MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE No matter how secure, there is always the human factor. Last edited by Dumber; 15th November 2006 at 17:00.. |
|
#4
|
||||||||
|
||||||||
|
Dumber,
Thank you for that script. I should be able to modify it to suit many users, but it won't be quick! Regards, Sluice |
|
#5
|
||||||||
|
||||||||
|
Just one other question:
Dumber, your script goes into the user's registry and amends their printer setting. Is there any way of editing the roaming profile on the profile server? |
|
#6
|
||||||||||
|
||||||||||
|
Quote:
I would use the script so that it makes that change when they log on. Then when they log off the settings should be saved back (unless you are using mandatory or readonly profiles).
__________________
Server 2000 MCP Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com ** Remember to give credit where credit is due and leave reputation points |
|
#7
|
||||||||||
|
||||||||||
|
Just like what Tony said.
I've used it as a loginscript.
__________________
Marcel Netherlands http://www.phetios.com http://blog.nessus.nl MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE No matter how secure, there is always the human factor. |
|
#8
|
||||||||
|
||||||||
|
Quote:
i just thought i might sugest you with the following code: Set WshNetwork = CreateObject("WScript.Network") RemovePrinters 'Remove All connected printer Function RemovePrinters() Dim PrinterCollection, i Set PrinterCollection = WshNetwork.EnumPrinterConnections For i = 0 To PrinterCollection.Count -1 Step 2 If PrinterCollection(i) <> "" Then 'On Error Resume Next If InStr(PrinterCollection.Item(i+1),"\\") <>0 Then WshNetwork.RemovePrinterConnection PrinterCollection.Item(i+1),True End If End If Next Set PrinterCollection = Nothing End Function 'Clean up Set WshNetwork = Nothing Set PrinterCollection = Nothing WScript.Quit regards, amit. |
|
#9
|
||||||||||
|
||||||||||
|
AMit,
Thanks. That can work indeed. The script i wrote was in 2003, when i needed is very fast. So i've created it quick and dirty
__________________
Marcel Netherlands http://www.phetios.com http://blog.nessus.nl MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE No matter how secure, there is always the human factor. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Allow users to edit all fields in GAL? | armstrongtj | Exchange 2000 / 2003 | 5 | 22nd August 2006 12:56 |
| Moving users settings/files | TheDonkey | Active Directory | 1 | 26th May 2006 03:43 |
| Moving 'Documents and Settings' for *all users* | Jerome | GPO | 5 | 24th September 2005 10:45 |
| Change settings under Restricted users account | pcking999 | Active Directory | 2 | 6th April 2005 23:18 |
| Lock down printer settings | tonyyeb | Windows Server 2000 / 2003 | 2 | 12th January 2005 20:26 |