Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for disablecompattelrunner.bat

(view source code of disablecompattelrunner.bat as plain text)

  1. @ECHO OFF
  2. IF NOT "%~2"=="" GOTO Syntax
  3. IF NOT "%~1"=="" IF /I NOT "%~1"=="/R" GOTO Syntax
  4. :: Version 6.1.* for Windows 7, 6.2.* for Windows 8
  5. :: VER | FINDSTR.EXE /R /C:" 6\.[12]\." >NUL || GOTO Syntax
  6. VER | FIND.EXE " 6.1." >NUL || GOTO Syntax
  7.  
  8. SETLOCAL
  9.  
  10. :: Enable or Disable the scheduled tasks, depending on optional command line switch /R
  11. IF /I "%~1"=="/R" (
  12.     SET Action=Enable
  13. ) ELSE (
  14.     SET Action=Disable
  15. )
  16.  
  17. ECHO.
  18. ECHO.========
  19. ECHO AitAgent
  20. ECHO.========
  21. ECHO.
  22. CALL :ModifyTask "AitAgent"
  23. ECHO.
  24. ECHO.=================================
  25. ECHO Microsoft Compatibility Appraiser
  26. ECHO.=================================
  27. ECHO.
  28. CALL :ModifyTask "Microsoft Compatibility Appraiser"
  29. ECHO.
  30. ECHO.==================
  31. ECHO ProgramDataUpdater
  32. ECHO.==================
  33. ECHO.
  34. CALL :ModifyTask "ProgramDataUpdater"
  35. ECHO.
  36.  
  37. ENDLOCAL
  38. GOTO:EOF
  39.  
  40.  
  41. :ModifyTask
  42. :: Test current "before" status
  43. ECHO Before:
  44. ECHO.-------
  45. SCHTASKS.EXE /Query  /TN "Microsoft\Windows\Application Experience\%~1"
  46. SET Test=
  47. :: Variable "Test" will be set to "Disabled" ONLY if the scheduled task is already disabled AND the requested action is disabling the tasks
  48. IF "%Action%"=="Disable" (
  49.     FOR /F "tokens=*" %%A IN ('SCHTASKS.EXE /Query  /TN "Microsoft\Windows\Application Experience\%~1"') DO (
  50.         FOR %%B IN (%%A) DO (
  51.             SET Test=%%B
  52.         )
  53.     )
  54. )
  55. :: If task is already disabled, do not try to disable it again
  56. IF "%Test%"=="Disabled" (
  57. 	ECHO.
  58. 	ECHO Scheduled task "Microsoft\Windows\Application Experience\%~1" has already been disabled.
  59. ) ELSE (
  60. 	ECHO.
  61. 	ECHO Changing:
  62. 	ECHO.---------
  63. 	SCHTASKS.EXE /Change /TN "Microsoft\Windows\Application Experience\%~1" /%Action%
  64. 	ECHO.
  65. 	ECHO After:
  66. 	ECHO.------
  67. 	SCHTASKS.EXE /Query  /TN "Microsoft\Windows\Application Experience\%~1"
  68. )
  69. GOTO:EOF
  70.  
  71.  
  72. :Syntax
  73. ECHO.
  74. :: ECHO DisableCompatTelRunner.bat,  Version 1.00 for Windows 7 or 8
  75. ECHO DisableCompatTelRunner.bat,  Version 1.00 for Windows 7
  76. ECHO Disable scheduled Application Experience tasks to speed up Windows startup
  77. ECHO.
  78. ECHO Usage:  DisableCompatTelRunner  [ /R ]
  79. ECHO.
  80. ECHO Where:  /R  will Reenable the scheduled tasks
  81. ECHO.
  82. :: ECHO Notes:  This script disables/reenables CompatTelRunner.exe on Windows 7 or 8.
  83. ECHO Notes:  This batch file disables or reenables CompatTelRunner.exe on Windows 7.
  84. ECHO         Run it without any command line argument to disable the scheduled tasks
  85. ECHO         AitAgent, Microsoft Compatibility Appraiser, and ProgramDataUpdater,
  86. ECHO         all located in "Microsoft\Windows\Application Experience"; or run it
  87. ECHO         again with the /R switch to reenable the tasks.
  88. ECHO.
  89. ECHO         Performance improved tremendously on the computers I tested this on:
  90. ECHO         before I disabled the tasks, the computers would be unusable for
  91. ECHO         about 20 minutes after logging in, regularly freezing; now I can
  92. ECHO         start using them right away.
  93. ECHO.
  94. ECHO         RUNNING THIS BATCH FILE MAY NEGATIVELY AFFECT SYSTEM PERFORMANCE
  95. ECHO         OR FUTURE WINDOWS UPGRADES. MAKE SURE YOU HAVE A VALIDATED BACKUP
  96. ECHO         AVAILABLE BEFORE RUNNING THIS BATCH FILE.
  97. ECHO         USE THIS BATCH FILE ENTIRELY AT YOUR OWN RISK.
  98. ECHO.
  99. ECHO Written by Rob van der Woude
  100. ECHO http://www.robvanderwoude.com
  101. EXIT /B 1
  102.  

page last modified: 2024-02-26; loaded in 0.0117 seconds