mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 Migrate Network Printers the easy way - PrintSwap

Author Message
edavis6678

  • Total Posts : 123
  • Scores: 0
  • Reward points : 0
  • Joined: 1/12/2006
  • Status: offline
Migrate Network Printers the easy way - PrintSwap Wednesday, June 27, 2007 6:42 AM (permalink)
0
Here's a real simple script if you are in the process of migrating from 1 windows printer server to another.  (or if you ever want to migrate from 1 printer share to a new printer share)

Run this as part of a login script, or interactively.

Rememeber to change line 7 of the script to note the name of your INPUT file.  Format of file is simple TXT file, (i use CSV extension so you can modify in excel).  Make sure input file is in same directory as script.

Format is as follows:

\\OLDSERVERNAME\OLDPRINTERSHARENAME, \\NEWSERVERNAME\NEWSHARENAME
\\SERVERNAME\OLDPRINTERSHARENAME, \\SERVERNAME\NEWSHARENAME

Enjoy

-E

 
 On Error Resume Next
 ' PrintSwap vbs - Author, Eric Davis- edavis6678 -at- Y a h o o . com
 Dim oNetwork, oFso, oShell, InputFileName
 Set oShell   = WScript.CreateObject("WScript.Shell")
 Set oNetwork = WScript.CreateObject("WScript.Network")
 Set oFso= CreateObject("Scripting.FileSystemObject")
 InputFileName = "redirect_list.csv" ' Make sure this files is located in SAME directory as this script
 'Format of files is as follows
 '\\OLDSERVERNAME\OLDPRINTERSHARENAME, \\NEWSERVERNAME\NEWSHARENAME
 '\\SERVERNAME\OLDPRINTERSHARENAME, \\SERVERNAME\NEWSHARENAME
 Set oPrinters = oNetwork.EnumPrinterConnections
 For i = 0 to oPrinters.Count - 1 Step 2
 Print = oPrinters.Item(i)
 PrintDev = oPrinters.Item(i+1)
 '########## CALL TO CHECK PRINTERS AND CHANGE IF NECESSARY
 Call ReMapPrinter(PrintDev) 
 Next
 'End of Script
 Sub ReMapPrinter(OldPrinter)
 booldontadd = 0
 sScriptDir = Left(WScript.ScriptFullName, Len(WScript.ScriptFullName) - Len(WScript.ScriptName)) ' Path of script
 InputFile = sScriptDir & "\" & InputFileName ' path of inputfile
 Set TempFile = ofso.openTextFile(InputFile) ' read through file
 While Not TempFile.atendofstream
  TextLine = Trim(TempFile.Readline)
  aryLine = Split(TextLine,",")
  printerpath = lcase(aryLine(1))
  If printerpath = "" Then ' If printer is listed, but no value given for new printer then just remove old printer
   booldontadd = 1
  Else
   booldontadd = 0
  End If
  oldprinterpath = lcase(aryLine(0))
  If lcase(OldPrinter) = oldprinterPath Then
   ' get current default printer
   DefaultKey = LCase(oShell.RegRead("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"))
   DefPrinter = Split(DefaultKey, ",")
   If booldontadd = 0 Then ' must have new target, if none, printer removed.
    oNetwork.AddWindowsPrinterConnection printerpath
   End If
   oNetwork.RemovePrinterConnection oldprinterPath ' remove old printer
    If DefPrinter(0) = oldprinterpath Then 
     oNetwork.SetDefaultPrinter PrinterPath ' if it was the default, reset it back to default
    End If
  End If
 Wend
 End Sub
 
 
#1
    dm_4ever

    • Total Posts : 3673
    • Scores: 82
    • Reward points : 0
    • Joined: 6/29/2006
    • Location: Orange County, California
    • Status: offline
    RE: Migrate Network Printers the easy way - PrintSwap Wednesday, June 27, 2007 1:28 PM (permalink)
    0
    How weird...I just wrote one to do the same thing for someone at work.
    dm_4ever

    My philosophy: K.I.S.S - Keep It Simple Stupid
    Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
    Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
    #2
      ebgreen

      • Total Posts : 8081
      • Scores: 94
      • Reward points : 0
      • Joined: 7/12/2005
      • Status: offline
      RE: Migrate Network Printers the easy way - PrintSwap Thursday, June 28, 2007 3:59 AM (permalink)
      0
      I have one too.
      "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
      Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
      http://www.visualbasicscript.com/m_47117/tm.htm
      #3
        edavis6678

        • Total Posts : 123
        • Scores: 0
        • Reward points : 0
        • Joined: 1/12/2006
        • Status: offline
        RE: Migrate Network Printers the easy way - PrintSwap Thursday, June 28, 2007 5:23 AM (permalink)
        0
        hehe.
         
        I'm doing major printer mig at my new job. x32 to x64 clusters...had to dig my old mig script out  ;)...figured I'd post and share.
         
        Looks like printer deployment is getting easier though with R2...
         
         
        #4
          ebgreen

          • Total Posts : 8081
          • Scores: 94
          • Reward points : 0
          • Joined: 7/12/2005
          • Status: offline
          RE: Migrate Network Printers the easy way - PrintSwap Thursday, June 28, 2007 6:32 AM (permalink)
          0
          [sarcasm] Sure it is... [/sarcasm]
          "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
          Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
          http://www.visualbasicscript.com/m_47117/tm.htm
          #5
            edavis6678

            • Total Posts : 123
            • Scores: 0
            • Reward points : 0
            • Joined: 1/12/2006
            • Status: offline
            RE: Migrate Network Printers the easy way - PrintSwap Thursday, June 28, 2007 7:12 AM (permalink)
            0
            ok..slightly , but related to migrating printers.

            I'm keepign the old server up for about a week as the script runs through the flipping of users...however I want to watch the old server for printing - in case someoen is still printing to the old server. 

            I've written a script that monitors a windows server for SYSTEM log Event ID #10),  however on this old server there are no event ID 10.  (it seems someone must have turned it off). - i know this cause the new server I built HAS event ID 10's.

            Anyone know how to turn that off/on?  (I'd like to eventually turn it off the new server cause I dot'n want tthat spamming theh event log)

            Thanks

            -E
             
            PS EVent ID 10 is written to the system event log when someone prints.
            #6
              andreas

              • Total Posts : 15
              • Scores: 0
              • Reward points : 0
              • Joined: 4/12/2007
              • Location: Sweden / Kalmar
              • Status: offline
              RE: Migrate Network Printers the easy way - PrintSwap Wednesday, July 11, 2007 8:23 PM (permalink)
              0

              ORIGINAL: edavis6678

              ok..slightly , but related to migrating printers.

              I'm keepign the old server up for about a week as the script runs through the flipping of users...however I want to watch the old server for printing - in case someoen is still printing to the old server. 

              I've written a script that monitors a windows server for SYSTEM log Event ID #10),  however on this old server there are no event ID 10.  (it seems someone must have turned it off). - i know this cause the new server I built HAS event ID 10's.

              Anyone know how to turn that off/on?  (I'd like to eventually turn it off the new server cause I dot'n want tthat spamming theh event log)

              Thanks

              -E

              PS EVent ID 10 is written to the system event log when someone prints.


              Check the Print server properties for the following flag (checkbox option)
              "log spooler information events"
              and
              "Notify when remote documents are printed"

              Cheers

              #7
                edavis6678

                • Total Posts : 123
                • Scores: 0
                • Reward points : 0
                • Joined: 1/12/2006
                • Status: offline
                RE: Migrate Network Printers the easy way - PrintSwap Thursday, July 12, 2007 4:37 AM (permalink)
                0
                (I neglected to post that I found that check box) -- sometimes I get a bit anxious for a fix.
                 
                Thanks for the reply though!
                 
                -E
                #8

                  Online Bookmarks Sharing: Share/Bookmark

                  Jump to:

                  Current active users

                  There are 0 members and 1 guests.

                  Icon Legend and Permission

                  • New Messages
                  • No New Messages
                  • Hot Topic w/ New Messages
                  • Hot Topic w/o New Messages
                  • Locked w/ New Messages
                  • Locked w/o New Messages
                  • Read Message
                  • Post New Thread
                  • Reply to message
                  • Post New Poll
                  • Submit Vote
                  • Post reward post
                  • Delete my own posts
                  • Delete my own threads
                  • Rate post

                  2000-2012 ASPPlayground.NET Forum Version 3.8
                  mbt shoes www.wileywilson.com