mattb47

REPLACE-CALC.BAT

Oct 6th, 2018
314
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. rem REPLACE-CALC.BAT
  3. rem
  4. rem Replace the default Windows calculator (calc.exe) with
  5. rem Moffset Freecalc (http://www.moffsoft.com/freecalc.htm)
  6. rem
  7. rem Windows 10's calculator has a terrible UI.  Moffset's is free,
  8. rem and while not beautiful, is much more usable.
  9. rem
  10. rem The batch commands below use debbugger routines in the registry as noted here:
  11. rem
  12. rem https://stackoverflow.com/questions/2984846/set-image-file-execution-options-will-always-open-the-named-exe-file-as-defaul
  13. rem
  14. rem Note that a different calculator could easily be used instead by changing
  15. rem the "\Moffset Freecalc\MoffFreeCalc.exe" below to something else.
  16. rem
  17. rem The Image File Execution debugger technique used here could be used to
  18. rem replace other Windows built-in apps as well.  (E.g., Notepad++
  19. rem replacing notepad.exe.)
  20. rem
  21. rem by Matthew Borcherding
  22. rem matt@borchtech.com
  23. rem updated 10-06-2018
  24.  
  25.    setlocal
  26.  
  27. rem
  28. rem Check if on a 64-bit OS.  Setup program files directory accordingly.
  29. rem
  30.  
  31.    set pf=%programfiles%
  32.    if %PROCESSOR_ARCHITECTURE%==AMD64 set pf=%programfiles(x86)%
  33.  
  34. rem
  35. rem The %pf% variable is now set to the "%programfiles%" directory
  36. rem on 32-bit systems, and the "%programfiles(x86)%" directory
  37. rem on 64-bit systems,
  38. rem
  39.  
  40. rem
  41. rem Now double-check that Moffset FreeCalc is installed.
  42. rem No point to do this if it's not already installed.
  43. rem
  44.  
  45.    if not exist "%pf%\Moffsoft FreeCalc\MoffFreeCalc.exe" goto end
  46.  
  47. rem
  48. rem OK, Freecalc is installed.  Let's set the proper registry keys.
  49. rem
  50.  
  51.    reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\calc.exe" /v "Debugger" /t REG_SZ /d "%pf%\Moffsoft FreeCalc\MoffFreeCalc.exe" /f
  52.  
  53.  
  54. :end
  55. rem
  56. rem Done!
  57. rem
RAW Paste Data