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
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 | 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<pre class=" brush: vb; title: ; notranslate " title=" "> 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 </pre>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<pre class=" brush: vb; title: ; notranslate " title=" "> 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 </pre>00",0, True msgbox NomOrdinateur |
0 Comments