;; KixGenerated: 2009/05/14 12:08:57 ; PrintMigrate - Migrates printers from one server to another ; Glenn Barnas - 2006/04/14 ; ; Enumerates all printers, moving printers mapped on the old server to the new server ; assumes that old and new printer names are the same. The default printer is preserved. ; Only one print server (per pass) can be migrated with this utility ; ; The old and new print servers must be defined below ; ; If the old and new printer names are not the same, or printers are being moved between ; multiple print servers, use PrintMigrate2, which utilizes a lookup table to map the old ; server\printer to new server\printer. PrintMigrate2 utilizes a similar process to ; PrintMigrate, but is slower due to the 1:1 mapping needed. Break On Dim $ Dim $Printer ; printer BaseName Dim $OldPSvr, $NewPSvr ; old/new print server names Dim $LPKey ; Key where printers are defined Dim $DefPtr ; UNC of default printer Dim $Value ; value read from registry Dim $I ; index pointer Dim $Tag ; flag indicating an error in delete/map process $ = SetOption('Explicit', 'On') $ = SetOption('WrapAtEOL', 'On') $ = SetOption('NoVarsInStrings', 'On') $ = SetOption('NoMacrosInStrings', 'On') ;############################################################## ; Define old & new print servers $OldPSvr = '\\oldprintserver' $NewPSvr = '\\newprintserver' ;############################################################## ; define key where printers are defined $LPKey = 'HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts' ; Get current default printer $DefPtr = ReadValue('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows', 'Device') ; Enumerate the printers defined for this user $I = 0 ; set the index to 0 ; get the first registry value $Value = EnumValue($LPKey, $I) While Not @ERROR If $I = 0 Cls ; Display the default printer If $DefPtr 'Default printer is ' Split($DefPtr, ',')[0] ? ? Else 'Default printer is not defined.' ? ? EndIf ; process until an EOD error EndIf 'Checking ' $Value $Tag = 0 ; clear the error tag If InStr($Value, $OldPSvr) ; If it references the old server $Printer = Join(Split($Value, $OldPSvr), '') ; get the printer name DelPrinterConnection($Value) ; delete the current printer connection If Not @ERROR ; handle error ' - deleted' Else ' Failed to delete printer!' ? $Tag = 1 EndIf If Not $Tag ; add if delete was successful AddPrinterConnection($NewPSvr + $Printer) If Not @ERROR ', added' Else ' Failed to add printer!' ? $Tag = 1 EndIf If Not $Tag If InStr($DefPtr, $Printer) SetDefaultPrinter($NewPSvr + $Printer) If Not @ERROR ', Set as default' Else ' Failed to set as default printer!' ? EndIf EndIf EndIf ? EndIf $I = 0 ; restart the enumeration Else ' - OK' ? $I = $I + 1 ; increase the enumeration pointer EndIf $Value = EnumValue($LPKey, $I) Loop
Just change the "oldprintserver" and "newprintserver" names.
Glenn
Generated in 0.07 seconds in which 0.028 seconds were spent on a total of 14 queries. Zlib compression enabled.
") !=-1) { tempah=tempah.substring(tempah.indexOf("")+5,tempah.indexOf("")); codes[i].innerHTML="" + dotag(tempah.substring()) + ""; } } //var pres = document.getElementsByTagName("pre"); //for (var i=0, maxi = pres.length; i < maxi; i++) { // var tempah = pres[i].innerHTML; // if (tempah.indexOf("[postprep") !=-1) { // tempah=tempah.substring((tempah.indexOf("]",tempah.indexOf("[postprep"))+1)); // pres[i].innerHTML=dotag(tempah); // } //} function ytag(which_one) { var codes = document.getElementsByClassName("ubbcode-body"); var thisone = codes[which_one].innerHTML; codes[which_one].innerHTML = "" + dotag(thisone.substring(5+thisone.indexOf(""),thisone.indexOf(""))) + ""; var heads = document.getElementsByClassName("ubbcode-header"); heads[which_one].innerHTML = "Code:" + ' '; } function ttag(which_one) { var codes = document.getElementsByClassName("ubbcode-body"); var thisone = ""; if (codes[which_one].innerText != undefined) { thisone += codes[which_one].innerText; } else { thisone += codes[which_one].textContent; } codes[which_one].innerHTML = thisone + ""; var heads = document.getElementsByClassName("ubbcode-header"); heads[which_one].innerHTML = "Code:" + ' '; }
")+5,tempah.indexOf("
" + dotag(tempah.substring()) + "
" + dotag(thisone.substring(5+thisone.indexOf(""),thisone.indexOf(""))) + "
"),thisone.indexOf("
"; if (codes[which_one].innerText != undefined) { thisone += codes[which_one].innerText; } else { thisone += codes[which_one].textContent; } codes[which_one].innerHTML = thisone + "