Prev: New Installation
Next: Getting rid of phantom hotkey
From: mwebb on 21 Apr 2008 22:36 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
From: Leonard Grey on 22 Apr 2008 00:01 NumLock can also be set in the BIOS, which may be overriding your script. --- Leonard Grey Errare humanum est mwebb wrote: > 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 > > > >
From: Trevor Bloomer on 22 Apr 2008 04:40 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. -- Kind regards, Trevor Bloomer "mwebb" <mwebb(a)discussions.microsoft.com> wrote in message news:A50E3B67-C981-42A7-B9CC-0E613DF22458(a)microsoft.com... > 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 > > > >
From: smlunatick on 22 Apr 2008 16:54 MiumLock options in BIOS are ignored for every Windows version based on NT (NT, 2000, XP, 2003, 2008 and Vista.) On 22/04/2008 Leonard Grey <Leonard(a)Grey.invalid> wrote: >NumLock can also be set in the BIOS, which may be overriding your script. > >--- >Leonard Grey >Errare humanum est > >mwebb wrote: >> 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 ?bjWMIService.ExecQuery("Select * From Win32_OperatingSystem" >> , , 48) >> For Each objItem in colItems >> strOS = objItem.Name >> Next >> 'WScript.Echo strOS >> >> >> strOSSearch ?XP" >> intOSType ?nStr(strOS,strOSSearch) >> >> 'If OS is not XP quit. If not check registry key >> If intOSType ? 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 ?shShell.RegRead("HKEY_USERS\.DEFAULT\Control >> Panel\Keyboard\InitialKeyBoardIndicators") >> WScript.Echo "Final RegVal: " & intRegVal >> >> >> WScript.Quit >> >> >> >>
From: Klaus Jorgensen on 23 Apr 2008 13:36 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. -- /klaus
|
Pages: 1 Prev: New Installation Next: Getting rid of phantom hotkey |