anchor.diff:  :::::::::::::::::::::
   :: PREP AND CHECKS ::
   :::::::::::::::::::::
  -set STAGE_2_SCRIPT_VERSION=1.1.7
  -set STAGE_2_SCRIPT_DATE=2016-10-27
  +set STAGE_2_SCRIPT_VERSION=1.2.0
  +set STAGE_2_SCRIPT_DATE=2016-11-01
   
   :: Quick check to see if we inherited the appropriate variables from Tron.bat
   if /i "%LOGFILE%"=="" (
  
positive.code: ::                2. Safe mode is strongly recommended (though not required)
  ::                3. Called from tron.bat. If you try to run this script directly it will error out
  :: Author:        vocatus on reddit.com/r/TronScript ( vocatus.gate at gmail ) // PGP key: 0x07d1490f82a211a2
  :: Version:       1.1.7 * Significantly improve robustness of OneDrive checks. OneDrive now only removed if system is Win10, folder exists in default location, and is empty. Thanks to /u/ranger_dood
  ::                1.1.6 * Suppress output of by_name debloat by default, and add support for VERBOSE switch to affect this step and display output to the console instead of log file
  ::                1.1.5 / Swap order of Toolbar/BHO removal and by_name removal. Performing uninstalls by_name often forces a reboot so we do it last
  ::                      ! Correct a reference to USERPROFILE that should've used Tron's USERPROFILES instead
  
negative.code: :: JOB: Remove crapware programs, phase 1: by specific GUID
  title Tron v%SCRIPT_VERSION% [stage_2_de-bloat] [Remove bloatware by GUID]
  call functions\log.bat "%CUR_DATE% %TIME%    Attempt junkware removal: Phase 1 (by specific GUID)..."
  call functions\log.bat "%CUR_DATE% %TIME%    Tweak here: \resources\stage_2_de-bloat\oem\programs_to_target_by_GUID.txt"
  if /i %DRY_RUN%==no (
  	REM This is required so we can check the errorlevel inside the FOR loop
  	SETLOCAL ENABLEDELAYEDEXPANSION
  
  	REM Verbose output check
  	if /i %VERBOSE%==yes echo Looking for:
  
  	REM Loop through the file...
  	for /f %%i in (stage_2_de-bloat\oem\programs_to_target_by_GUID.txt) do (
  		REM  ...and for each line: a. check if it is a comment or SET command and b. perform the removal if not
  		if not %%i==:: (
  		if not %%i==set (
  			if /i %VERBOSE%==yes echo    %%i
  			start /wait msiexec /qn /norestart /x %%i >> "%LOGPATH%\%LOGFILE%" 2>nul
  			REM Check if the uninstaller added entries to PendingFileRenameOperations if it did, export the contents, nuke the key value, then continue on
  			reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations >nul 2>&1
  			if !errorlevel!==0 (
  				echo Offending GUID: %%i >> "%RAW_LOGS%\PendingFileRenameOperations_export.txt"
  				reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations >> "%RAW_LOGS%\PendingFileRenameOperations_export.txt"
  				reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations /f >nul 2>&1
  				if /i %VERBOSE%==yes echo  ^^! Detected filenames in PendingFileRenameOperations. Entries exported to "%RAW_LOGS%\PendingFileRenameOperations_export.txt" and deleted.
  				echo  ^^! Detected filenames in PendingFileRenameOperations. Entries exported to "%RAW_LOGS%\PendingFileRenameOperations_export.txt" and deleted. >> "%LOGPATH%\%LOGFILE%"
  				echo ------------------------------------------------------------------- >> "%RAW_LOGS%\PendingFileRenameOperations_export.txt"
  				)
  			)
  		)
  	)
  	ENDLOCAL DISABLEDELAYEDEXPANSION
  )
  call functions\log.bat "%CUR_DATE% %TIME%    Done."
  
  
  :: JOB: Remove crapware programs, phase 3: unwanted toolbars and BHOs by GUID
  title Tron v%SCRIPT_VERSION% [stage_2_de-bloat] [Remove toolbars by GUID]
  call functions\log.bat "%CUR_DATE% %TIME%    Attempt junkware removal: Phase 2 (toolbars by specific GUID)..."
  call functions\log.bat "%CUR_DATE% %TIME%    Tweak here: \resources\stage_2_de-bloat\oem\toolbars_BHOs_to_target_by_GUID.txt"
  if /i %DRY_RUN%==no (
  	REM This is required so we can check errorlevel inside the FOR loop
  	SETLOCAL ENABLEDELAYEDEXPANSION
  
  	REM Verbose output check
  	if /i %VERBOSE%==yes echo Looking for:
  
  	REM Loop through the file...
  	for /f %%i in (stage_2_de-bloat\oem\toolbars_BHOs_to_target_by_GUID.txt) do (
  		REM  ...and for each line: a. check if it is a comment or SET command and b. perform the removal if not
  		if not %%i==:: (
  		if not %%i==set (
  			if /i %VERBOSE%==yes echo    %%i
  			start /wait msiexec /qn /norestart /x %%i >> "%LOGPATH%\%LOGFILE%" 2>nul
  			REM Check if the uninstaller added entries to PendingFileRenameOperations if it did, export the contents, nuke the key value, then continue on
  			reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations >nul 2>&1
  			if !errorlevel!==0 (
  				echo Offending GUID: %%i >> "%RAW_LOGS%\PendingFileRenameOperations_export.txt"
  				reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations >> "%RAW_LOGS%\PendingFileRenameOperations_export.txt"
  				reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations /f >nul 2>&1
  				if /i %VERBOSE%==yes echo  ^^! Detected filenames in PendingFileRenameOperations. Entries exported to "%RAW_LOGS%\PendingFileRenameOperations_export.txt" and deleted.
  				echo  ^^! Detected filenames in PendingFileRenameOperations. Entries exported to "%RAW_LOGS%\PendingFileRenameOperations_export.txt" and deleted. >> "%LOGPATH%\%LOGFILE%"
  				echo ------------------------------------------------------------------- >> "%RAW_LOGS%\PendingFileRenameOperations_export.txt"
  				)
  			)
  		)
  	)
  	ENDLOCAL DISABLEDELAYEDEXPANSION
  )
  call functions\log.bat "%CUR_DATE% %TIME%    Done."
  
  
  