Thursday, September 24, 2009

Registry: Hide Locked User Name on Windows 7

Borrowing from Daniel Petri's post on how to hide the display of the logged-on user when a Windows 7 computer is locked, I wanted to try to do this in different languages/scripts for the hell of it.

CMD console using REG.exe...

REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DontDisplayLockedUserId /t REG_DWORD /d 3 /f

VBScript using Registry object...

Const HKEY_LOCAL_MACHINE = &H80000002
' more at http://msdn2.microsoft.com/en-us/library/aa394600.aspx

Sub AddKey(strComputer, strKeyPath)
    Set objReg=GetObject( _
        "winmgmts:{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\default:StdRegProv")
    objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
End Sub
Post Options
Sub AddDWValue(strComputer, strKeyPath, strValueName, iValue)
    Set objReg=GetObject( _
        "winmgmts:{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\default:StdRegProv")
 objReg.SetDWordValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, iValue
End Sub

Const k = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
AddKey "Computer1", k
AddDWValue "Computer1", k, "DontDisplayLockedUserId", 3

KiXtart...

$k = "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System"
$=WriteValue($k, "DontDisplayLockedUserId", 3, "REG_DWORD")

This was thrown together pretty quick so it might need tweaking.

No comments:

Post a Comment