Redondance dans les serveurs d'impression – Serveur d’impression

Author: Titanfall —

Short summary: J'ai ce script pour ça. Je l'ai eu d'un site web il y a des années … Code: '------------------------------------------------ 'Auteur: Isaac G 'Date: 4/29/2008 'Script pour mettre à jour les imprimantes installées des utilisateurs vers 'utiliser un serveur d'impression secondaire ' Option explicite Dim PF, StrHostPrintsrv1 Set PF = New PrinterFailover StrHostPrintsrv1 = "YOURPRIMARYPRINTSERVERNAME" Si […]

Quick overview

Site
Tutos GameServer
Canonical URL
https://tutos-gameserver.fr/2019/09/05/redondance-dans-les-serveurs-dimpression-serveur-dimpression/
LLM HTML version
https://tutos-gameserver.fr/2019/09/05/redondance-dans-les-serveurs-dimpression-serveur-dimpression/llm
LLM JSON version
https://tutos-gameserver.fr/2019/09/05/redondance-dans-les-serveurs-dimpression-serveur-dimpression/llm.json
Manifest
https://tutos-gameserver.fr/llm-endpoints-manifest.json
Estimated reading time
4 minutes (217 seconds)
Word count
722

Key points

Structured content

J'ai ce script pour ça. Je l'ai eu d'un site web il y a des années …

Code: '------------------------------------------------ 'Auteur: Isaac G 'Date: 4/29/2008 'Script pour mettre à jour les imprimantes installées des utilisateurs vers 'utiliser un serveur d'impression secondaire '

Option explicite

Dim PF, StrHostPrintsrv1 Set PF = New PrinterFailover

StrHostPrintsrv1 = "YOURPRIMARYPRINTSERVERNAME" Si Ping (StrHostPrintsrv1) = False alors PF.PS_PROD = "YOURPRIMARYPRINTSERVERNAME" PF.PS_BACKUP = "YOURSECONDARYPRINTSERVERNAME" Autre PF.PS_PROD = "VOTRESECONDARYPRINTSERVERNAME" PF.PS_BACKUP = "YOURPRIMARYPRINTSERVERNAME" Fin si Fonction publique Ping (strHost)

    Dim objPing, objRetStatus

    set objPing = GetObject ("winmgmts: impersonationLevel = impersonate"). ExecQuery _       ("select * from Win32_PingStatus où address = '" & strHost & "'")

    pour chaque objRetStatus dans objPing         si IsNull (objRetStatus.StatusCode) ou objRetStatus.StatusCode <> 0, alors     Ping = False             'WScript.Echo "Le code d'état est" & objRetStatus.StatusCode         autre             Ping = True             'Wscript.Echo "Bytes =" & vbTab & objRetStatus.BufferSize             'Wscript.Echo "Time (ms) =" & vbTab & objRetStatus.ResponseTime            'Wscript.Echo "TTL (s) =" & vbTab & objRetStatus.ResponseTimeToLive         fin si     suivant Fonction de fin

PF.UpdatePrinters

WScript.Quit

Classe PrinterFailover

'Publique

Public PS_PROD Public PS_BACKUP

'Privé

Privé oShell Privé HKEY_CURRENT_USER Privé HKCU_DEFAULT_PRINTER

Private Sub Class_Terminate () Définir oShell = Nothing End Sub

Private Sub Class_Initialize () Définir oShell = WScript.CreateObject ("WScript.Shell") HKEY_CURRENT_USER = & H80000001

'Rev2 HKCU_DEFAULT_PRINTER = "HKCU Logiciel Microsoft Windows NT CurrentVersion Windows Device" 'end rev2

End Sub

Fonction publique UpdatePrinters ()

Dim v, ar, i, j

ar = arPrinters ()

Dim retValueNames Dim retValueTypes

SKeyPath: sKeyPath = "Imprimantes Connexions "

Dim RegFullKeyPath

Dim arRegVal ()

Dim nName: nName = 0 Dim nType: nType = 1 Dim nVal: nVal = 2

'rev2 Dim PrintersUpdated: PrintersUpdated = False Dim DefPrinter: DefPrinter = DefaultPrinter () 'End rev 2

Pour i = 0 à UBound (ar, 1)

Si InStr (ar (i), PS_PROD)> 0 alors

'WScript.Echo "Mise à jour de la clé d'imprimante:" & ar (i)

'rev2 PrintersUpdated = True 'end rev2

RegFullKeyPath = sKeyPath & ar (i)

Appelez EnumRegVals (RegFullKeyPath, _ retValueNames, _ retValueTypes)

ReDim arRegVal (3, UBound (retValueNames))

Pour j = 0 à UBound (retValueNames) 'WScript.Echo "nom de la valeur:" & retValueNames (j) & ":" & oShell.RegRead ("HKCU " & RegFullKeyPath & "" & retValueNames (j))

arRegVal (nName, j) = retValueNames (j)

arRegVal (nType, j) = RegTypeNameFromVal (retValueTypes (j))

arRegVal (nVal, j) = oShell.RegRead ("HKCU " & RegFullKeyPath & "" & retValueNames (j))

Prochain

oShell.RegDelete "HKCU " & RegFullKeyPath & ""

Pour j = 0 à UBound (arRegVal, 2) oShell.RegWrite Replace ("HKCU " & RegFullKeyPath & "" & arRegVal (nName, j), PS_PROD, PS_BACKUP), _ Remplacez (arRegVal (nVal, j), PS_PROD, PS_BACKUP), _ arRegVal (nType, j) Prochain

Fin si Prochain

'rev2 'Ne mettez à jour l'imprimante par défaut que si nous avons échoué Si PrintersUpdated Then UpdateDefaultPrinter (DefPrinter) Fin si 'end rev2

Fonction de fin

Public Sub EnumRegVals (ByVal sKeyPath, _ ByRef retValueNames, _ ByRef retValueTypes)

'Référence WMI

'http://msdn.microsoft.com/en-us/library/aa390387(VS.85).aspx

Dim sComp: sComp = "." Dim i, oReg

Définissez oReg = GetObject ("winmgmts: impersonationLevel = impersonate! \" & _ sComp & " root default: StdRegProv")

oReg.EnumValues ​​HKEY_CURRENT_USER, sKeyPath, _ retValueNames, retValueTypes

End Sub

Fonction privée RegTypeNameFromVal (RegType) const REG_SZ = 1 const REG_EXPAND_SZ = 2 const REG_BINARY = 3 const REG_DWORD = 4 const REG_MULTI_SZ = 7

Dim s

Sélectionner le type de cas Case REG_SZ s = "REG_SZ" Cas REG_EXPAND_SZ s = "REG_EXPAND_SZ" Affaire REG_BINARY s = "REG_BINARY" Case REG_DWORD s = "REG_DWORD" Affaire REG_MULTI_SZ s = "REG_MULTI_SZ" 'bien que RegWrite ne supporte pas ce type Fin Sélectionnez

RegTypeNameFromVal = s

Fonction de fin

Fonction privée arPrinters ()

Dim sComp: sComp = "." SKeyPath: sKeyPath = "Imprimantes Connexions" Dim ar, sous-clé, oReg

Définissez oReg = GetObject ("winmgmts: impersonationLevel = impersonate! \" & _ sComp & " root default: StdRegProv")

oReg.EnumKey HKEY_CURRENT_USER, sKeyPath, ar

arPrinters = ar Fonction de fin

'rev2 Fonction privée DefaultPrinter () Dim s s = oShell.RegRead (HKCU_DEFAULT_PRINTER) DefaultPrinter = s Fonction de fin

Private Sub UpdateDefaultPrinter (DefPrinter) oShell.RegWrite HKCU_DEFAULT_PRINTER, Remplacer (DefPrinter, PS_PROD, PS_BACKUP) End Sub

'end rev2

Classe de fin

Click to rate this post! [Total: 0 Average: 0]

Topics and keywords

Themes: Serveur d'impression

License & attribution

License: CC BY-ND 4.0.

Attribution required: yes.

Manifest: https://tutos-gameserver.fr/llm-endpoints-manifest.json

LLM Endpoints plugin version 1.1.2.