anchor.diff:  ::                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.0 * Move embedded Win10 metro de-bloat code to PowerShell sub-scripts
  +:: Version:       1.1.1 ! Only set registry flag to allow starting AppX service in Safe Mode if the system is already in Safe Mode
  +::                      / Move OneDrive removal from Metro debloat to its own job
  +::                      * Don't remove OneDrive if any files are present in the default OneDrive folder
  +::                      * Disable OneDrive links in Explorer side pane via registry keys, instead of deleting the keys entirely
  +::                      - Remove redundant "net start AppXSVC" line prior to Metro de-bloat code
  +::                1.1.0 * Move embedded Win10 metro de-bloat code to PowerShell sub-scripts
   ::                1.0.1 - Remove internal log function and switch to Tron's external logging function. Thanks to github:nemchik
   ::                1.0.0 + Initial write
   @echo off
  
positive.code: :: Version checks
  if %WIN_VER_NUM% geq 6.2 set TARGET_METRO=yes
  if /i %PRESERVE_METRO_APPS%==yes set TARGET_METRO=no
  if /i %DRY_RUN%==no net start AppXSVC >nul 2>&1
  if /i %TARGET_METRO%==yes (
  	call functions\log.bat "%CUR_DATE% %TIME%    Windows 8 or higher detected, removing OEM Metro apps..."
  	:: Force allowing us to start AppXSVC service in Safe Mode. AppXSVC is the MSI Installer equivalent for "apps" (vs. programs)
  	if /i %DRY_RUN%==no (
  		REM Enable starting AppXSVC in Safe Mode
  		reg add "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\%SAFEBOOT_OPTION%\AppXSVC" /ve /t reg_sz /d Service /f >nul 2>&1
  		net start AppXSVC >nul 2>&1
  		REM Enable scripts in PowerShell
  		powershell "Set-ExecutionPolicy Unrestricted -force 2>&1 | Out-Null"
  
  		REM Do the removal
  		if /i not "%WIN_VER:~0,9%"=="Windows 1" (
  
  			REM Windows 8/8.1 version
  			REM In Windows 8/8.1 we can blast ALL AppX/Metro/"Modern App" apps because unlike in Windows 10, the "core" apps (calculator, paint, etc) aren't in the "modern" format
  			powershell "Get-AppXProvisionedPackage -online | Remove-AppxProvisionedPackage -online 2>&1 | Out-Null"
  			powershell "Get-AppxPackage -AllUsers | Remove-AppxPackage 2>&1 | Out-Null"
  
  		) else (
  
  			REM Windows 10 version
  			REM Kill forced OneDrive integration
  			taskkill /f /im OneDrive.exe >> "%LOGPATH%\%LOGFILE%" 2>&1
  			%SystemRoot%\System32\OneDriveSetup.exe /uninstall >> "%LOGPATH%\%LOGFILE%" >nul 2>&1
  			%SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall >> "%LOGPATH%\%LOGFILE%" >nul 2>&1
  			REM These keys are orphaned after the OneDrive uninstallation and can be safely removed
  			reg delete "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f >> "%LOGPATH%\%LOGFILE%" 2>&1
  			reg delete "HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f >> "%LOGPATH%\%LOGFILE%" 2>&1
  			takeown /f "%LocalAppData%\Microsoft\OneDrive" /r /d y >> "%LOGPATH%\%LOGFILE%" 2>&1
  			icacls "%LocalAppData%\Microsoft\OneDrive" /grant administrators:F /t >> "%LOGPATH%\%LOGFILE%" 2>&1
  			rmdir /s /q "%LocalAppData%\Microsoft\OneDrive" >> "%LOGPATH%\%LOGFILE%" 2>&1
  			rmdir /s /q "%ProgramData%\Microsoft OneDrive" >> "%LOGPATH%\%LOGFILE%" 2>&1
  			rmdir /s /q "%SystemDrive%\OneDriveTemp" >> "%LOGPATH%\%LOGFILE%" 2>&1
  
  			REM Call the external PowerShell scripts to do removal of Microsoft and 3rd party OEM Modern Apps
  			powershell -executionpolicy bypass -file ".\stage_2_de-bloat\metro\metro_3rd_party_modern_apps_to_target_by_name.ps1"
  			powershell -executionpolicy bypass -file ".\stage_2_de-bloat\metro\metro_Microsoft_modern_apps_to_target_by_name.ps1"
  
negative.code: :::::::::::::::::::::
  :: PREP AND CHECKS ::
  :::::::::::::::::::::
  set STAGE_2_SCRIPT_VERSION=1.1.1
  set STAGE_2_SCRIPT_DATE=2016-01-18
  
  :: Quick check to see if we inherited the appropriate variables from Tron.bat
  if /i "%LOGFILE%"=="" (
  