2 simple vbs scripts to disable Number Lock for Windows 7 and Windows XP

By | February 17, 2012
Share

Just two simple scripts I wrote up to disable number lock on Windows 7 and Windows XP. They import the Default hive and then set the InitialKeyIndicator setting to “0”.

Win XP Script:

On Error Resume Next
'==========VARIABLE ASSIGNMENTS=========================
Dim objFSO, objShell, sCurPath
Set objShell = CreateObject("WScript.Shell")

strCommand = "reg load HKLM\defhive ""C:\Documents and Settings\Default User\NTUSER.DAT"""
objShell.Run strCommand, 0, True

objShell.RegWrite "HKLM\defhive\Control Panel\Keyboard\InitialKeyboardIndicators", "0"

strCommand = "reg unload HKLM\defhive"
objShell.Run strCommand, 0, True

Win 7 Script:

On Error Resume Next
'==========VARIABLE ASSIGNMENTS=========================
Dim objShell, sCurPath, strCommand
Set objShell = CreateObject("WScript.Shell")

strCommand = "reg load HKLM\defhive c:\Users\Default\NTUSER.DAT"
objShell.Run strCommand, 0, True

objShell.RegWrite "HKLM\defhive\Control Panel\Keyboard\InitialKeyboardIndicators", "0"

strCommand = "reg unload HKLM\defhive"
objShell.Run strCommand, 0, True

-Brian G.

One thought on “2 simple vbs scripts to disable Number Lock for Windows 7 and Windows XP

  1. Rich

    Brian! I basically have numlock working as a runonce in the reg. Below are the files:

    NUMLOCK.VBS
    set WshShell = CreateObject(“Wscript.Shell”)
    WshShell.SendKeys “{NUMLOCK}”

    RUNONCE.REG
    Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]
    “Logon”=”cscript.exe c:\\windows\\numlock.vbs”

    [HKEY_USERS\Default\Software\Microsoft\Windows\CurrentVersion\RunOnce]
    “Logon”=”cscript.exe c:\\windows\\numlock.vbs”

    NUMLOCK.BAT
    reg load “hku\Default” “C:\Users\Default\NTUSER.DAT”
    reg import “C:Windows\runonce.reg”
    reg unload “hku\default”

    I get most of this. I did this a very long time ago. However, the part that escapes me is the loading, importing and unloading the default DAT file. I am not using VM’s any longer. I have a completely clean OS and everything from the ground up gets installed to create my full image.
    What I wish to accomplish is to have ‘authenticated users’ get full control of a folder ‘when’ it gets created. Once a user launches an application, the foldername gets added to their appdata\local\folder, and that folder MUST have authenticated users having full control. We do it manually, or should.
    I know that your numlock is something that happens on an event, the log on. Can this be tailored somehow so that the event is the app being launched (which creates the appdata\local\folder and the authenticated users get full control? I tried it once but it immediately made the folder before the app was launched.
    The app itself auto-creates the folder, in the mfg exe, but for each user who launches the app, I’d like authenticated users to have full control of that folder.

    Reply

Leave a Reply

Your email address will not be published.

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.