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 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.