0byt3m1n1
Path:
C:
/
Windows
/
Setup
/
Scripts
/
[
Home
]
File: Hyper-V-BIOSLock.vbs
' Hyper-V-BIOSLock 04/01/09 '******************************************************************************* ' Options '******************************************************************************* Option Explicit '******************************************************************************* Dim NAME Dim COPYRIGHT Dim VERSION Dim DATE NAME="Hyper-V-BIOSLock" COPYRIGHT="Copyright (c) Fujitsu Technology Solutions 2009" VERSION="2.0" DATE="07-Aug-2009" '******************************************************************************* ' Constants '******************************************************************************* 'from "XGEN: Windows Management Instrumentation Error Return Codes" Const WBEM_E_INVALID_NAMESPACE = -2147217394 '0x8004100E Const WBEM_E_ILLEGAL_OPERATION = -2147217378 '0x8004101E Const DebugFlag = False '******************************************************************************* ' Implementation '******************************************************************************* '******************************************************************************* ' functions/subroutines '******************************************************************************* Sub ErrorMessage(Name) if Err.Number <> 0 then WScript.Echo "Error " & Err.Number & " occured after " & Name WScript.Echo "exiting..." WScript.Quit end if End Sub 'WScript.Echo 'WScript.Echo NAME & " (Version " & VERSION & ", " & DATE & ")" 'WScript.Echo COPYRIGHT 'WScript.Echo '------------------------------------------------------------------------------- ' Read the Vendor String '------------------------------------------------------------------------------- Dim OEMuniqueIdentifier OEMuniqueIdentifier = " " Dim ManufacturerLength Dim ManufacturerName Dim SystemSet Dim System Set SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("Win32_ComputerSystem") if Err.Number <> 0 then ErrorMessage("GetObject Win32_ComputerSystem") for each System in SystemSet if (DebugFlag) then WScript.Echo "System.Manufacturer: " & System.Manufacturer & ", Length = " & Len(System.Manufacturer) ManufacturerLength = Len(System.Manufacturer) if ManufacturerLength > 0 AND ManufacturerLength <= Len(OEMuniqueIdentifier) Then ManufacturerName = System.Manufacturer do while Len (ManufacturerName) < Len(OEMuniqueIdentifier) ManufacturerName = ManufacturerName & " " loop OEMuniqueIdentifier = ManufacturerName end if next if (DebugFlag) then WScript.Echo "OEMuniqueIdentifier: " & OEMuniqueIdentifier & ", Length = " & Len(OEMuniqueIdentifier) '------------------------------------------------------------------------------- ' Set the BiosLockString '------------------------------------------------------------------------------- Dim oShell, BiosLockString Set oShell = CreateObject("WScript.Shell") on Error resume next BiosLockString = oShell.RegRead ("HKLM\Software\Microsoft\Windows NT\CurrentVersion\Virtualization\BiosLockString") if (Len(BiosLockString)) > 0 then if (DebugFlag) then WScript.Echo "BiosLockString = " & BiosLockString & ", Length = " & Len(BiosLockString) else oShell.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Virtualization\BiosLockString",OEMuniqueIdentifier, "REG_SZ" BiosLockString = oShell.RegRead ("HKLM\Software\Microsoft\Windows NT\CurrentVersion\Virtualization\BiosLockString") if (DebugFlag) then WScript.Echo "BiosLockString set: " & BiosLockString end if