troubleshooting Question

Could someone tell me what this vb script does? Thanks!

Avatar of Dopher
Dopher asked on
Visual Basic Classic
3 Comments1 Solution219 ViewsLast Modified:

' Start of Script
strOldPServ = "FL-Print1"
strNewPServ = "FL-File01"
strOldFServ = "FL-File1"
strNewFServ = "FL-File01"

strMessageLog = "Changing Printers Mappings from " & strOldPServ & " to " & strNewPServ & vbcrlf & _
"Changing Mapped Drives from " & strOldFServ & " to " & strNewFServ & vbcrlf

Set objNetwork = CreateObject("WScript.Network")

Set objPrinters = objNetwork.EnumPrinterConnections
      For i = 0 to objPrinters.Count - 1 Step 2
            strPrinter = objPrinters.Item(i+1)
      
            If Left(strPrinter, 2) = "\\" Then
                  strPrinter = Replace(strPrinter,"\\","")
                  PrinterArray = Split(strPrinter,"\")
            
                  PrintServer = PrinterArray(0)
                  Printer = PrinterArray(1)
            
                  If LCase(PrintServer) = LCase(strOldPServ) Then
                        objNetwork.RemovePrinterConnection (objPrinters.Item(i+1))
                        strMessageLog = strMessageLog & "Removed: " & objPrinters.Item(i+1) & vbcrlf
                        strNewPrinter = "\\" & strNewPServ & "\" & Printer
                        objNetwork.AddWindowsPrinterConnection(strNewPrinter)
                        strMessageLog = strMessageLog & "Added: " & strNewPrinter & vbcrlf
                  End if
            End If
      Next

Set aryMapDrives = objNetwork.EnumNetworkDrives
      For i = 0 to aryMapDrives.count -1 Step 2
            strDriveLtr = aryMapDrives(i)
            strDrivePath = aryMapDrives(i + 1)
            
            strDrivePath = Replace(strDrivePath,"\\","")
            aryDrivePath = Split(strDrivePath, "\", 2)


            FileServer = aryDrivePath(0)
            Path = aryDrivePath(1)

            If LCase(FileServer) = LCase(strOldFServ) Then
                  objNetwork.RemoveNetworkDrive(strDriveLtr)
                  strMessageLog = strMessageLog & "Removing: " & strDriveLtr & vbcrlf
                  strNewPath = "\\" & strNewFServ & "\" & Path
                  objNetwork.MapNetworkDrive strDriveLtr, strNewPath
                  strMessageLog = strMessageLog & "Mapping: " & StrDriveLtr & " to " & strNewPath
            End If




      Next
            
      msgBox strMessageLog,,"Florida Rollover Script"      



' End of Script
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros