IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

[VBS] Adapter une boucle dans mon script de modification de registre à distance


Sujet :

VBScript

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 24
    Par défaut [VBS] Adapter une boucle dans mon script de modification de registre à distance
    Bonjour,

    Voici mon script qui permet de modifier des clés de registre et je voudrais ajouter une boucle pour qu'il effectue cette modification pour un ensemble de machine que je renseigne dans un fichier texte.
    Pouvez vous m'aider et m'apporter une explication sur mettre en place une boucle je pige pas tout
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
     
    Const HKEY_LOCAL_MACHINE = &H80000002
     
    strComputer = "NomDuPC"
    Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
    strKeyPath ="Software\Enatel\WiseGuard\AdvancedLogin\"
    objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    ValueName = "DontCheckSecurityServices"
    dwValue = 1
    objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue 
     
    strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    ValueName = "TraceDir"
    strValue = C:\Temp
    objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, strValue
     
    strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    ValueName = "TraceLevel"
    dwValue = 5
    objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue
     
    strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    ValueName = "MaxFileSize"
    dwValue = 1388
    objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue
     
    strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    ValueName = "LimitedLogFiles"
    dwValue = 2
    objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue
    Merci d'avance pour votre aide

  2. #2
    Membre expérimenté
    Inscrit en
    Mai 2008
    Messages
    189
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 189
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    Const HKEY_LOCAL_MACHINE = &H80000002
    FichierSource = "Source.txt"
    Const ForReading = 1
    ScriptPath = Left(WScript.ScriptFullName,(Len(WScript.ScriptFullName) - (Len(WScript.ScriptName) + 1)))
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile(ScriptPath & "\" & Fichiersource, ForReading)
    Else
        Wscript.Echo "Fichier introuvable, tâche annulée"
    	Wscript.quit
    End If
    Do Until objTextFile.AtEndOfStream 
        strComputer = objTextFile.Readline
    	Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
    	strKeyPath ="Software\Enatel\WiseGuard\AdvancedLogin\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "DontCheckSecurityServices"
    	dwValue = 1
    	objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue 
     
    	strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "TraceDir"
    	strValue = C:\Temp
    	objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, strValue
     
    	strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "TraceLevel"
    	dwValue = 5
    	objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue
     
    	strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "MaxFileSize"
    	dwValue = 1388
    	objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue
     
    	strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "LimitedLogFiles"
    	dwValue = 2
    	objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue
    Loop
    essaie cà

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 24
    Par défaut
    Un grand merci

    Par contre j'ai du enlever les lignes de 7 à 10 il fait une erreur de syntaxe Ligne 7 "Else" et vu mon niveau lamentable, je pense que c'est contrôler la présence du fichier ?

    Je le passe pas en Résolu de suite, j'essaye de rajouter un rename de fichier plus copy

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 24
    Par défaut
    Voici le script

    Il modifie le registre + renommer un fichier + copie d'un fichier

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    Const HKEY_LOCAL_MACHINE = &H80000002
    FichierSource = "Source.txt"
    Const ForReading = 1
    ScriptPath = Left(WScript.ScriptFullName,(Len(WScript.ScriptFullName) - (Len(WScript.ScriptName) + 1)))
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile(ScriptPath & "\" & Fichiersource, ForReading)
    'Else
    '    Wscript.Echo "Fichier introuvable, tâche annulée"
    '	Wscript.quit
    'End If
    Do Until objTextFile.AtEndOfStream 
        strComputer = objTextFile.Readline
    	Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
    	strKeyPath ="Software\Enatel\WiseGuard\AdvancedLogin\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "DontCheckSecurityServices"
    	dwValue = 1
    	objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue 
     
    	strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "TraceDir"
    	strValue = "C:\Temp"
    	objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, strValue
     
    	strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "TraceLevel"
    	dwValue = 5
    	objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue
     
    	strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "MaxFileSize"
    	dwValue = 1388
    	objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue
     
    	strKeyPath = "SOFTWARE\Enatel\WiseGuard\Debug\"
    	objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    	ValueName = "LimitedLogFiles"
    	dwValue = 2
    	objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue
     
     
    'Renomer le fichier WGGina.dll
     
    Set objREP = CreateObject("Scripting.FileSystemObject")
    objREP.MoveFile "\\"& strComputer &"\C$\Program Files\Evidian\WG Advanced Login\WGGina.dll" , "\\"& strComputer &"\C$\Program Files\Evidian\WG Advanced Login\WGGina.dll.old"
     
    'Copie de la Nouvelle WGGINA.dll
     
    objREP.CopyFile "\\NomDuPC\C$\Script\Registre\WGGina.dll" , "\\"& strComputer &"\C$\Program Files\Evidian\WG Advanced Login\", OverWriteFiles
     
    Loop
    WScript.Quit
    Merci encore pour votre aide

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [MCD] une boucle dans mon MCD de gestion des gardes ! (c'est anormal ?)
    Par mechakiss dans le forum Schéma
    Réponses: 24
    Dernier message: 10/02/2012, 16h41
  2. [Activité] Représenter une "boucle" dans mon diagramme
    Par axool dans le forum Autres Diagrammes
    Réponses: 2
    Dernier message: 17/06/2011, 20h51
  3. Voyez vous une erreur dans mon script?
    Par pierrot10 dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 29/10/2009, 23h01
  4. [VBS] Erreur dans mon script "Robocopy+share+ACL"
    Par tofju dans le forum VBScript
    Réponses: 19
    Dernier message: 27/05/2009, 12h03
  5. [VBS] erreur dans mon script "création d'utilisateur AD"
    Par stefdu59 dans le forum VBScript
    Réponses: 8
    Dernier message: 07/05/2009, 16h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo