' ************************************************************ 
' fixreg.vbs
' get name of admin group via SID
' unlock registry entries
' ************************************************************ 

If MsgBox("Do you want to unlock tampered registry entries?" & vbCrLf & "Make sure you have administrator rights first!" & vbCrLf & vbCrLf &"Unlock now?", vbYesNo, WScript.Scriptname) = vbNo Then WScript.Quit

Set objWMI = GetObject("winmgmts:") 
strWQL = "select Name from win32_account where SID='S-1-5-32-544'" 
Set objResult = objWMI.ExecQuery(strWQL) 

For Each objAcc In objResult 
	strResult = objAcc.Name 
Next

set shell = CreateObject("WScript.Shell")

On Error Resume Next

	shell.run "subinacl /keyreg ""\HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi"" /grant=" & strResult
	If Err.Number<>0 Then
		If Err.Number = -2147024894 Then
			MsgBox "'SubInACL.exe' not found! Make sure you have 'SubInACL.exe' installed and that you run this 'fixreg.vbs' script from the same path!", vbCritical, "'SubInACL' utility not found!" 
			WScript.Quit
		Else
			MsgBox "Calling SubInACL failed on 'Scsi'-key:" & vbCrLf & Err.Number & Err.Description, vbCritical, "Error"
		End If
	End If

	shell.run "subinacl /keyreg ""\HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"" /grant=" & strResult
	If Err.Number<>0 Then MsgBox "Calling SubInACL failed on 'MountedDev'-key:" & vbCrLf & Err.Number & Err.Description, vbCritical, "Error"

On Error GoTo 0
