This script first verifies the presence of the Windows folder. If found, it proceeds to load the system registry, extracts the computer name, and subsequently unloads the registry. The retrieved computer name is then displayed in a message box.

VBS script

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")
NomOrdinateur = ""
If Fso.FolderExists("c:\Windows") = True Then shell.Run "reg.exe load HKLM
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")
NomOrdinateur = ""
If Fso.FolderExists("c:\Windows") = True Then shell.Run "reg.exe load HKLM\0000 " & chr(34) & "C:\WINDOWS\system32\config\system" & Chr(34),0,True
Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "0000\ControlSet001\Control\ComputerName\ComputerName"
strValueName = "Computername"
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,NomOrdinateur
shell.Run "cmd /c reg.exe unload HKLM\0000",0,True

msgbox NomOrdinateur
00 " & chr(34) & "C:\WINDOWS\system32\config\system" & Chr(34),0,True Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") strKeyPath = "0000\ControlSet001\Control\ComputerName\ComputerName" strValueName = "Computername" objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,NomOrdinateur shell.Run "cmd /c reg.exe unload HKLM
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")
NomOrdinateur = ""
If Fso.FolderExists("c:\Windows") = True Then shell.Run "reg.exe load HKLM\0000 " & chr(34) & "C:\WINDOWS\system32\config\system" & Chr(34),0,True
Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "0000\ControlSet001\Control\ComputerName\ComputerName"
strValueName = "Computername"
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,NomOrdinateur
shell.Run "cmd /c reg.exe unload HKLM\0000",0,True

msgbox NomOrdinateur
00",0,True msgbox NomOrdinateur


0 commentaire

Laisser un commentaire

Emplacement de l’avatar

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.