TronScript | Automating The Process of Disinfecting Windows Systems

Recently discovered this very handy utility which is an automated open source clean up tool. It runs a a total of 7 stages or 9 if you wish to use custom scripts and some tools that don’t support command-line use. Stages are Prep > Tempclean > De-bloat > Disinfect > Repair > Patch > Optimize > Wrap-Up. Everything is logged, and I mean everything to C:\Logs\tron\

STAGE 0: Prep

Create System Restore point: Create a pre-run system restore point. Vista and up only, client OS’s only (not supported on Server OS’s, and on Windows 10 does not work if the system is in any form of Safe Mode. This is a known bug, and I spent hours trying to find a workaround but was not able to find a solution, so if you absolutely require a system restore point, recommend running in normal mode

Rkill: Rkill is an anti-malware prep tool; it looks for and kills a number of known malware that interfere with removal tools. Rkill will NOT kill any process listed in \resources\stage_0_prep\rkill\rkill_process_whitelist.txt (link)

Create pre-run profile: Dump list of installed programs and list of all files on the system so we can compare later and see exactly what was removed

GUID dump: Dump list of all installed program GUIDs. These dumps are useful in helping the project bolster the blacklist of known-bad GUIDs

Safe mode: Set system to reboot into Safe Mode with Networking if a reboot occurs. Removes this and resets to normal bootup at the end of the script. Accomplished via this command:

bcdedit /set {default} safeboot network

Set system time via NTP: Set the system clock to sync against the following NTP servers, in this order: 2.pool.ntp.org, time.windows.com, time.nist.gov

Check and repair WMI: Check WMI interface and attempt repair if broken. Tron uses WMI for a lot of stuff including ISO date format conversion, OEM bloatware removal, and various other things, so having it functioning is critical

McAfee Stinger: Anti-malware/rootkit/virus standalone scanner from McAfee. Does not support plain-text logs so we save HTML log to Tron’s %LOGPATH%. Tron executes Stinger as follows:

Backup registry:: Use erunt to backup the registry prior to commencing scans

VSS purge: Purge oldest set of Volume Shadow Service files (basically snapshot-in-time copies of files). Malware can often hide out here

Reduce system restore space: Restrict System Restore to only use 7% of available hard drive space

Disable sleep mode: Tron uses caffeine.exe to disable sleep mode when the script starts. At the end of the script it resets power settings to Windows defaults. Use the -p flag prevents resetting power settings to Windows default.

STAGE 1: Tempclean

Internet Explorer cleanup: Executes only on Internet Explorer v7 and up. Runs the following built-in Windows tool to clean and reset Internet Explorer:

rundll32.exe inetcpl.cpl,ClearMyTracksByProcess 4351

CCLeaner: CCLeaner utility by Piriform. Used to clean temp files before running AV scanners. Note that CCleaner wipes %AppData% Local Storage. Edit ccleaner.ini and change (App)Local Storage*=True to (App)Local Storage*=False if you don’t want this behavior. Note that you must also do this for BleachBit (below)

BleachBit: BleachBit utility. Used to clean temp files before running AV scanners. Edit BleachBit.ini and disable any items you wish to preserve (for example, Local Storage for Chrome)

Cleanup duplicate downloads: Searches for and delete duplicate files found in the Downloads folders of each user profile (ChromeInstaller(1).exe, ChromeInstaller(2)exe, etc). Does not touch any other folders. Uses Sentex’s Find Dupe utility

Clear Windows event logs: Back up Windows event logs to %LOGPATH% directory, then clear all entries

Metro de-bloat: Remove many built-in Metro apps that aren’t commonly used (does NOT remove things like Calculator, Paint, etc) then purges them from the cache (can always fetch later from Windows Update). On Windows 8/8.1, removes all stock “Modern” apps. On Windows 10 and up, only removes a few specific Modern apps. You can see the full list of Metro apps removed here (Microsoft) and here (OEM/3rd party). Use the -sb switch (skip all de-bloat) or -m switch (skip only Metro de-bloat) to skip this action

STAGE 3: Disinfect

Malwarebytes Anti-Malware: Anti-malware scanner. Because there is no command-line support for MBAM, we simply install it and continue with the rest of the script. This way a tech can click Scan whenever they’re around, but the script doesn’t stall waiting for user input. Use the -sa or -sm flags skip this component

STAGE 4: Repair

DISM image check & repair: Microsoft utility for checking the Windows Image Store (sort of a more powerful System File Checker). Windows 8 and up only

Registry permissions reset: Grant SYSTEM and Administrator users full permissions on HKLM, HKCU, and HKCR hives. This is an add-only permissions operation (does not remove any permissions). Use the -srr flag skips this operation

Filesystem permissions reset: Grant SYSTEM and Administrator users full permissions on everything in the %WinDir% directory tree. Use the -sfr flag skips this operation

System File Checker: Microsoft utility for checking the filesystem for errors and attempting to repair if found. Tron runs this on Windows Vista and up only (XP and below require a reboot)

chkdsk: Checks disk for errors and schedules a chkdsk with repair at next reboot (marks volume dirty) if errors are found

Disable Windows “telemetry”: Disable Windows “telemetry” (user tracking), Windows 7 and up only. Tron removes the “bad” updates Microsoft pushed to Windows 7/8/8.1 systems after the Windows 10 release. These updates backport the surveillance/spyware functions that are by default present in Windows 10. See the code to see exactly which updates are removed. See the code (Win7/8/8.1, Win10) to see exactly which KB’s are removed. Tron also stops and deletes the DiagTrack (“Diagnostics Tracking Service”) service. If the system is running Windows 10, Tron does a more in-depth disabling of the Windows telemetry features, including automatically applying all the immunizations from the Spybot Anti-Beacon and O&O ShutUp10 tools. Go over the code in \tron\resources\stage_4_repair\disable_windows_telemetry\ to see exactly what is removed and disabled. NOTE: This section takes a LONG time to run, DO NOT CANCEL IT. Use the -str switch to just turn telemetry off instead of removing it

Disable Windows 10 upgrade: Disables the Windows 10 upgrade nagger on Windows 7/8/8.1 by flipping the appropriate registry switches. Users can still manually upgrade the machine if they desire, but it will no longer nag via the system tray, auto-download, or auto-install Windows 10 without their permission

STAGE 5: Patch

Tron updates these programs if they exist on the system. If a program does not exist, it is skipped:

7-Zip: Open-source compression and extraction tool. Far superior to just about everything (including the venerable WinRAR). Use the -sap switch to skip this action

Adobe Flash Player: Used by YouTube and various other sites. Use the -sap switch to skip this action

Adobe Reader: Standard PDF reader. Use the -sap switch to skip this action

Java Runtime Environment: I personally hate Java, but it is still widely used, so we at least get the system on the latest version. Use the -sap switch to skip this action

Windows updates: Runs Windows update via this command: wuauclt /detectnow /updatenow. Use the -swu switch to skip this action. If bundled WSUS Offline updates are detected, Tron executes those instead. Use the -swo switch to force skipping WSUS Offline updates even if they’re present in the relevant directory. See Executing bundled WSUS Offline updates above for more information on using offline update packages with Tron

DISM base reset: Recompile the “Windows Image Store” (SxS store). This typically results in multiple GB’s of space freed up. Windows 8 and up only. Any Windows Updates installed prior to this point will become “baked in” (uninstallable). Use the -sdc switch to skip this action

STAGE 6: Optimize

%WMIC% computersystem where name="%computername%" set AutomaticManagedPagefile=True

Use the -spr flag skips this action

Defraggler: Command-line defrag tool from Piriform that’s a little faster than the built-in Windows defragmenter. Defrag is automatically skipped if the system drive is an SSD. Use the -sd flag forces Tron to ALWAYS skip defrag

STAGE 7: Wrap-up

generate summary logs: Generate before and after logs detailing which files were deleted and which programs were removed. These are placed in <LOGPATH>\tron_summary_logs. Additionally, if -er flag was used or EMAIL_REPORT variable was set, these logs will be attached to the email that is sent out

Create restore point: Create a post-run system restore point to mirror the one we created in Stage 0: Prep. Vista and up only, client OS’s only, on Windows 10 does not work if the system is in any form of Safe Mode. See notes on System Restore in Stage 0 documentation for more information

email_report: Send an email report with the log file attached when Tron is finished. Requires you to specify your SMTP settings in \resources\stage_7_wrap-up\email_report\SwithMailSettings.xml

upload debug logs: Upload ‘tron.log’ and the system GUID dump (list of all installed program GUIDs) to the Tron developer (vocatus). Please use this option if possible, log files are extremely helpful in developing Tron! NOTE: tron.log can contain personal information like names of files on the system, the computer name, user name, etc, so if you’re concerned about this please look through a Tron log first to understand what will be sent. I don’t care what files are on random systems on the Internet, but just something to be aware of

Tron is a glorified batch file free and open-source script that automates the process of disinfecting and cleaning up Windows systems. It is built with heavy reliance on community input and updated regularly.