Created
December 8, 2016 20:27
-
-
Save ayancey/5849e53b4067991c6d132a63cb21f910 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''''''''''''''''''''''''''''' | |
' Purpose: Allows you to enter the drive letter of an external drive with a copy of Windows on it, returns computer name | |
' Requirements: Windows 7 (may support older OSes), Administrator (maybe) | |
' Written by: Alex Yancey | |
' Date: December 8, 2016 | |
''''''''''''''''''''''''''''' | |
const HKEY_LOCAL_MACHINE = &H80000002 | |
set objshell = CreateObject("Wscript.shell") | |
computer_name = InputBox("OS drive letter: ", "HDD Computer Name") | |
' Load hive | |
objshell.Run "reg.exe load HKLM\tempdefault " & computer_name & ":\Windows\System32\config\SYSTEM", 0, True | |
' Get registry value for computer name | |
Set objReg = GetObject("winmgmts:" & _ | |
"{impersonationLevel=Impersonate}!\\" & _ | |
"." & "\root\default:StdRegProv") | |
objReg.GetStringValue HKEY_LOCAL_MACHINE,"tempdefault\ControlSet001\Control\ComputerName\ComputerName", "ComputerName", cname | |
' Output | |
MsgBox(cname) | |
' Unload hive | |
objshell.Run "reg.exe unload HKLM\tempdefault", 0, True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment