Search code examples
batch-filestartupregedit

Import reg key using a bat file


The issue is that an update pushed to my devices keeps setting the NumLock to on and the users have to turn it off in order to log in on the laptops. I want the NumLock to be off and I need to check to see if it has been changed to on and change it back to off.

I have a registry key that I want to drop into remote computers' startup folder so it will run without any intervention, i.e. UAC, or "Are you sure?".

The key I need to change is: "HKEY_Users.DEFAULT\Control Panel\Keyboard\InitialKeyboardIndicators" /v 0 /t REG_SZ /f

The value I want to change is 2 and I need it to be v/0 to turn off the NumLock keyboard feature before users ever log in on the laptops.

I have exported this key and named it NumLockEdit.reg and can run it in a bat file as follows:

@ECHO OFF

NumLockEdit.reg

But, I want to have it run without any input from me or the user. No UAC or "Are you sure" questions.

I've also tried this,

@echo off

reg add "HKEY_Users\.DEFAULT\Control Panel\Keyboard\InitialKeyboardIndicators" /v 0 /t REG_SZ /f

I've even tried creating a shortcut to my bat file and running it as admin but I still get the UAC and Are you sure? message.

Any help with this will be greatly appreciated. Thank you.


Solution

  • Set-ItemProperty -Path 'Registry::HKU.DEFAULT\Control Panel\Keyboard' -Name "InitialKeyboardIndicators" -Value "2"