čtvrtek 29. listopadu 2012

Disable keyboard in windows (with commandline script)

My cat loves my keybaord. Here is how to disable it:

  1. regedit ... HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServiceskbdclassParameters
  2. create new DWORD value named AllowDisable and set value to 1
  3. reboot
  4. open Device manager and disable option will be visible.

You can also make a script using devcon from Windows Driver Kit. Its located in C:Program Files (x86)Windows Kits8.0Toolsx64devcon.exe

You will need device ID of your keyboard. You can get it from Device Manager or using devcon find * |  findstr /R /C:"board"

Script has to escalate priviledges so it looks like this:

@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%system32cacls.exe" "%SYSTEMROOT%system32configsystem"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%getadmin.vbs"

    "%temp%getadmin.vbs"
    exit /B

:gotAdmin
    if exist "%temp%getadmin.vbs" ( del "%temp%getadmin.vbs" )
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------

devcon disable "HIDVID_045E&PID_00DB&MI_00*

Where HIDVID_045E&PID_00DB&MI_00* is my keyboard ID. It looks actually like this: USBVID_045E&PID_00DB&MI_007&28157AAF&0&0000 but using this the devcon fails to find it. So I used wildcard.

Žádné komentáře:

Okomentovat