Jump to content

Search the Community

Showing results for tags 'migrate'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. So, this is not one of my neatest scripts, but I haven't contributed much to the forum lately, and this was a help to me this week. I was migrating about 40 print queues from an old print server to a new one. Since this entails removing the old printer and creating the new printer for each user on each PC for each print queue used (for about 350 users), doing this manually was out of the question. I just added this to the logon scripts to run once per user per machine. If anyone finds the need to make a similar migration, please feel free to use/modify this. Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ;don't want to crash out if there is a problem. #include "PrintMgr.au3" ;https://www.autoitscript.com/forum/topic/155485-printers-management-udf/ #include "ServiceControl.au3" ;https://www.autoitscript.com/forum/topic/6487-updated-service-control-funtions/ #include <array.au3> Global $sOldPrintServer = "oldservername" Global $sNewPrintServer = "newservername" Global $sDefaultPrinter = _CleanName(_GetDefaultPrinter()) ;If you change print queue names below, you may need to take that into account and modify $sDefaultPrinter as well. Global $aPrinters = _PrintMgr_EnumPrinter() If @error Then Exit Global $aReplaced[1] = [0] Global $sTempName ;remove printers that are mapped to old server For $iLoop = 1 To $aPrinters[0] If Not StringInStr($aPrinters[$iLoop], $sOldPrintServer) Then ContinueLoop ;not a printer we are concerned with $sTempName = $aPrinters[$iLoop] ConsoleWrite("Removing " & $sTempName & @CRLF) _PrintMgr_RemovePrinter($sTempName) $sTempName = _CleanName($sTempName) ;If you need to change a print queue name, modify $sTempName here before adding it to the array. _ArrayAdd($aReplaced, $sTempName) $aReplaced[0] = $aReplaced[0] + 1 Next ;Stop and re-start print spooler. This alleviated problems on a few machines. ConsoleWrite("Stopping Spooler" & @CRLF) _StopService(@ComputerName, "spooler") Sleep(1000) ConsoleWrite("Starting Spooler" & @CRLF) _StartService(@ComputerName, "spooler") Sleep(1000) ;remap to the new server (assuming all of the print queues have the same share name) For $iLoop = 1 To $aReplaced[0] Local $isdefault = False If $aReplaced[$iLoop] = $sDefaultPrinter Then $isdefault = True ConsoleWrite("Adding \\" & $sNewPrintServer & "\" & $aReplaced[$iLoop] & "(" & $isdefault & ")" & @CRLF) _PrintMgr_AddWindowsPrinterConnection("\\" & $sNewPrintServer & "\" & $aReplaced[$iLoop]) If $isdefault Then _PrintMgr_SetDefaultPrinter("\\" & $sNewPrintServer & "\" & $aReplaced[$iLoop]) Next Func _GetDefaultPrinter() ; CyberSlug - 18 Nov 2004 Local $key, $default, $defPrtNm If @OSType = "WIN32_WINDOWS" Then $key = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers" $defPrtNm = RegRead("HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\Print\Printers", "Default") Else ;WIN_NT type $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers" $default = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device") $defPrtNm = StringLeft($default, StringInStr($default, ",") - 1) EndIf Return $defPrtNm EndFunc ;==>_GetDefaultPrinter Func _CleanName($sName) Local $sTempName = $sName $sTempName = StringReplace($sTempName, "\\" & $sOldPrintServer & "\", "") Return $sTempName EndFunc ;==>_CleanName Func MyErrFunc() ;just dump the info to the console and keep going Local $sErrNum Local $sMsg $sErrNum = Hex($oMyError.Number, 8) $sMsg = "Error Number: " & $sErrNum & @CRLF $sMsg &= "WinDescription: " & $oMyError.WinDescription & @CRLF $sMsg &= "Script Line: " & $oMyError.ScriptLine & @CRLF ConsoleWrite($sMsg) EndFunc ;==>MyErrFunc
×
×
  • Create New...