[VBS] Modification Clé Base de registre

Zwitter -  
 Zwitter -
Bonjour,

Je souhaite modifier a l'aide d'un script VB une Valeur de la base de registre. Voici un de mes codel :

HKEY_LOCAL_MACHINE = &H80000002
strComputer = "NOM-PC"
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\"
objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
ValueName = "SyncDomainWithMemberShip"
dwValue = 0
objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue 


Celui-ci marche parfaitement, cependant il faut qu'il change la valeure pour une liste de pc présent dans un fichier.
De plus il me faut aussi changer une valeure REG_SZ, mais je ne trouve pas la syntaxe.

Merci de votre aide et bonne journée.

Romain
Configuration: Windows XP
Firefox 2.0.0.9

3 réponses

  1. Zwitter
     
    Je fourni le code pour la valeure REG_SZ si jamais quelqun en a besoin. Il modifie les Suffixe DNS avec un ordre d'utilisation sur un poste distant ou non. (Je cherche encore comment le faire pour une liste de PC dans un fichier)

    HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "NOM-PC"
    Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
    strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\"
    objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
    ValueName = "SearchList"
    strValue = "PREMIER-DNS,SECOND"                             ' troisieme, quatrieme, ...
    objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, strValue 
    
    
    2
  2. le père
     
    Bonjour

    pour changer une valeur REG_SZ, voir site microsoft :

    The SetStringValue method sets the data value for a named value whose data type is REG_SZ.
    uint32 SetStringValue(
    [in] uint32 hDefKey,
    [in] string sSubKeyName,
    [in] string sValueName,
    [in] string sValue
    );

    donc essaye
    ...
    strvalue = "un texte REG_SZ"
    objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, strValue
    1
  3. Zwitter
     
    Merci beaucoup papa, sa marche niquel.
    Il me manque a l'executer pour une liste de postes contenu dans un fichier et jen aurai fini.

    a++
    0