Announcement

Collapse
No announcement yet.

Edit users' printer settings

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Edit users' printer settings

    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
    Re: Edit users' printer settings

    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
    Last edited by tonyyeb; 15th November 2006, 13:53. Reason: Being slow in the brain
    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 sigpic where appropriate **

    Comment


    • #3
      Re: Edit users' printer settings

      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
      Last edited by Dumber; 15th November 2006, 15:00.
      Marcel
      Technical Consultant
      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."

      "Enjoy life today, tomorrow may never come."
      "If you're going through hell, keep going. ~Winston Churchill"

      Comment


      • #4
        Re: Edit users' printer settings

        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

        Comment


        • #5
          Re: Edit users' printer settings

          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?

          Comment


          • #6
            Re: Edit users' printer settings

            Originally posted by sluice View Post
            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?
            Not as easy as it sounds i think. Registry settings IIRC are in the NTUSER.DAT (or .MAN) and would need some way of editing that.

            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 sigpic where appropriate **

            Comment


            • #7
              Re: Edit users' printer settings

              Just like what Tony said.
              I've used it as a loginscript.
              Marcel
              Technical Consultant
              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."

              "Enjoy life today, tomorrow may never come."
              "If you're going through hell, keep going. ~Winston Churchill"

              Comment


              • #8
                Re: Edit users' printer settings

                Originally posted by Dumber View Post
                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
                [/CODE]
                Hey dumber
                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.

                Comment


                • #9
                  Re: Edit users' printer settings

                  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
                  Technical Consultant
                  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."

                  "Enjoy life today, tomorrow may never come."
                  "If you're going through hell, keep going. ~Winston Churchill"

                  Comment

                  Working...
                  X