Share this page 

Turn CAPSLOCK on/off from a batch fileTag(s): Misc Prog HowTo


In this HowTo, we saw how to toggle the CAPS state using the Word.appplication object from vbscript. Since the required scripting is simple, it's easy to integrate it in a batch file.
set BAT_HOME=%~dp0
echo %BAT_HOME%
cd %BAT_HOME%
echo Set objShell = CreateObject("WScript.Shell") > temp.vbs
echo Set objWord = CreateObject( "Word.Application" ) >> temp.vbs
echo if objWord.CapsLock ^<^> 0 then >> temp.vbs
echo objShell.SendKeys "{capslock}" >> temp.vbs
echo end if >> temp.vbs
echo objWord.Quit >> temp.vbs
cscript //nologo temp.vbs
del temp.vbs
echo ... do your thing in the batch file