Citation :
Option Explicit
Dim WshShell, WshFS, WshNet, val, flagkey, isXP, is9x
Dim computername, logfile, logfilename
Set WshShell = CreateObject("Wscript.Shell" )
Set WshFS = CreateObject("Scripting.FileSystemObject" )
Set WshNet = CreateObject("WScript.Network" )
computername = WshNet.computername
logfilename="\\serveur\logmaj.txt"
On Error Resume Next 'trap d'erreur
'Détection de l'os
val = WshShell.RegRead("HKLM/Software/Microsoft/Windows/currentversion/productName" ) '9x
val = WshShell.RegRead("HKLM/Software/Microsoft/Windows NT/currentversion/productName" ) 'xp
is9x = (val="Microsoft Windows 95" or val="Microsoft Windows 98" or val="Microsoft Windows ME" )
isXP = (val="Microsoft Windows XP" )
val = WshShell.RegRead("<chemin vers la clé>" )
If val="" Then flagkey=0
On Error Goto 0 'fin du trap d'erreur
If flagkey=0 Then
If isXP Then WshShell.Run "regedit /s appxp.reg",2,True
ElseIf is9x Then WshShell.Run "regedit /s app9x.reg",2,True
Set logfile = WshFS.opentextfile(logfilename,8) '2: écrase, 8:ajout
LogFile.WriteLine computername&" mise à jour"
logfile.close
Set logfile = nothing
End If
'cleanup
Set WshShell = nothing
Set WshFS = nothing
Set WshNet = nothing
|