Sunday, April 19, 2015

How can I update the registry values every time Windows starts?



There's this annoyance in windows where applications are constantly stealing your focus. I find it very very annoying because I need to work on parallel tasks.



However, I found some registry values that can be updated in windows so that the focus steal is disabled. The problem is that this only works until windows is restarted the next time. After that it reverts back to its default behavior.




How can I ensure that the following keys are updated in windows after every restart (without any manual intervention).




HKEY_CURRENT_USER\Control Panel\Desktop Edit UserPreferenceMask value
to be 9F 3E 07 80 12 00 00 00 (there are many numbers in here, I only
had to update the 9F 3E 07 parts and the rest of the value remained)



HKEY_CURRENT_USER\Control Panel\Desktop Edit ActiveWndTrkTimeout,
change to 150 in decimal




HKEY_CURRENT_USER\Control Panel\Desktop Edit ForegroundFlashCount,
change to something like 7000 in decimal



and finally, I set this though from what I read it may/likely not do
anything in Windows Vista+ (this was the first thing I tried and it
didn't work, but I left it):



HKEY_CURRENT_USER\Control Panel\Desktop Edit ForegroundLockTimeout
to something very large (e.g. 9999999 in decimal)




Log off and log back in; so far programs that I KNOW steal focus are
silently resting in the background now and flashing me on the taskbar,
patiently waiting for me... AHHHHHHHH!



Answer



I worked on the direction suggested by Alex and arrived at the following solution:




  1. Create .bat file on windows


  2. Enter the following code into the file:




@Echo Off echo 'success' Title Reg Converter v1.2 & Color 1A cd
%systemroot%\system32 call :IsAdmin



Reg.exe add "HKCU\Control Panel\Desktop" /v "ActiveWndTrackTimeout" /t
REG_DWORD /d "150" /f Reg.exe add "HKCU\Control Panel\Desktop" /v
"ForegroundFlashCount" /t REG_DWORD /d "7000" /f Reg.exe add

"HKCU\Control Panel\Desktop" /v "ForegroundLockTimeout" /t REG_DWORD
/d "9999999" /f Reg.exe add "HKCU\Control Panel\Desktop" /v
"UserPreferencesMask" /t REG_BINARY /d "9f3e078012000000" /f Exit



:IsAdmin Reg.exe query "HKU\S-1-5-19\Environment" If Not %ERRORLEVEL%
EQU 0 ( Cls & Echo You must have administrator rights to continue ...
Pause & Exit ) Cls goto:eof






  1. Add this to Windows Task scheduler to run at startup (Note that adding it to startup causes problems because the script needs admin access).


  2. While creating the Task be sure to check the elevated privileges checkbox



No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...