NUM Lock Quandry

M

mwebb

At the request of my boss I have trying to run a script that will keep the
Num Lock on in XP. The idea is to set the registry key so that no matter what
the Num Lock is when the user logs off it will always be on at logon.

The script (below) is run as a logoff script that sets the value for Num
Lock on when the user logs off. The script runs fine and places the number in
the correct place in the registry but when the logon happens the Num Lock key
is off if the user had the key off when logging off before the script runs.

What is really frusturating is that the Num Lock key value is "on" after
logon but the actual key is off.

I am running the script to run synchronisly.

Apparently XP is reading the Num Lock key after the logoff script is run.
Running the script as logon script does not work either.

How can I get this script to work so the Num Lock is always on no matter
what the Num Lock setting is on logoff.

--------------------------------
'This logoff script uses WMI to determine the OS. If the OS is other than
WinXP the script quits.
'If the OS is WinXP the shell object is used to place a 2 in the registry so
at the next logon the
'Num Lock key is on.

Dim strComputer
Dim objWMIService
Dim colItems
Dim objItem
Dim strOS
Dim intOSType
Dim strOSSearch
Dim intRegVal

strComputer = "."

'Determine OS
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem"
, , 48)
For Each objItem in colItems
strOS = objItem.Name
Next
'WScript.Echo strOS


strOSSearch = "XP"
intOSType = InStr(strOS,strOSSearch)

'If OS is not XP quit. If not check registry key
If intOSType = 0 Then
WScript.Quit

'If keyboard indicator is 2 quit. If not place "2" in the key
Else
Set WshShell = CreateObject("Wscript.Shell")
intRegVal = WshShell.RegRead("HKEY_USERS\.DEFAULT\Control
Panel\Keyboard\InitialKeyBoardIndicators")
WScript.Echo "Initial RegVal: " & intRegVal
If intRegVal <> 2 Then
WshShell.RegWrite"HKEY_USERS\.DEFAULT\Control
Panel\Keyboard\InitialKeyBoardIndicators" , 2, "REG_SZ"

End If
End If

intRegVal = WshShell.RegRead("HKEY_USERS\.DEFAULT\Control
Panel\Keyboard\InitialKeyBoardIndicators")
WScript.Echo "Final RegVal: " & intRegVal


WScript.Quit
 
T

Trevor Bloomer

Instead of running your script, try changing the registry value for NumLock
at "HKU\Default\ControlPanel\Keyboard" from 0 to 2.
It's one of the first tweaks I do every time I have to re-install Windows
XP.
 
S

smlunatick

MiumLock options in BIOS are ignored for every Windows version based on NT
(NT, 2000, XP, 2003, 2008 and Vista.)
 
K

Klaus Jorgensen

mwebb wrote :
The script (below) is run as a logoff script that sets the value for Num
Lock on when the user logs off. The script runs fine and places the number in
the correct place in the registry but when the logon happens the Num Lock key
is off if the user had the key off when logging off before the script runs.

Why are you modifying the registry for the Default User. IIRC that part
of the registry is used only as a template when a user logs on for the
first time. Use the HKCU branch instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top