Skip to content

ThinApp Cleanup Script

Once a ThinApp project is saved there can be some files captured that are not required. These can be removed to avoid them being included in the final ThinApp exe. This improves the performance of the ThinApp and reduces the file size. I wrote a batch script which you can paste into the root of the project folder which automatically cleans up the project by moving common files to the support folder in the project. The Support folder does not get captured in the ThinApp build so can be used to store cleanup files temporarily to make sure the ThinApp works OK after cleanup.

This script performs the following steps:

  1. Creates a cleanup folder structure in the support folder of the project
  2. Moves common folders to be cleaned up from the project to the support\cleanup folder
  3. Copy RES folder and VB Script to correct locations in project for RES Workspace Manager to detect and manage the ThinApp
  4. Print folder list and file size of cleanup and save as text file in support folder
  5. Delete the ThinApp_Cleanup.bat file itself after it has finished.

Download the script ThinApp_Cleanup.bat as a text file and rename the extension to .bat

Script is use at own risk please feel free to ask any questions.

Below is the code:

GOTO :---
ThinApp Cleanup Script by Imran Qureshi
Date: 17/06/2014
Description: This will move the folders to the Support\Cleanup folder which does not go into the bin exe.

1. Make a backup of the whole Project.
2. Add/Remove common paths below to exclude if required.
3. Paste this batch file into the root of the Project folder and double click as standard user to run.
4. Rebuild ThinApp and test that it is working.

:: Create Cleanup Folder structure
MD "%~dp0Support\Cleanup"
MD "%~dp0Support\Cleanup\%%AppData%%"
MD "%~dp0Support\Cleanup\%%Common AppData%%"
MD "%~dp0Support\Cleanup\%%Common AppData%%\Microsoft"
MD "%~dp0Support\Cleanup\%%Local AppData%%Low"
MD "%~dp0Support\Cleanup\%%Desktop%%"
MD "%~dp0Support\Cleanup\%%drive_C%%"
MD "%~dp0Support\Cleanup\%%Profile%%"
MD "%~dp0Support\Cleanup\%%Program Files Common%%"
MD "%~dp0Support\Cleanup\%%ProgramFilesDir%%"
MD "%~dp0Support\Cleanup\%%SystemRoot%%"
MD "%~dp0Support\Cleanup\%%SystemRoot%%\winsxs"
MD "%~dp0Support\Cleanup\%%Cookies%%"
MD "%~dp0Support\Cleanup\%%SystemSystem%%"

:: Exclude folders CA, McAfee, .Net, RES, cache, log and temp files
MOVE /Y "%%AppData%%\McAfee" "Support\Cleanup\%%AppData%%\McAfee"
MOVE /Y "%%Common AppData%%\McAfee" "Support\Cleanup\%%Common AppData%%\McAfee"
MOVE /Y "%%Common AppData%%\Microsoft\RAC" "Support\Cleanup\%%Common AppData%%\Microsoft\RAC"
MOVE /Y "%%Common AppData%%\Microsoft\Group Policy" "Support\Cleanup\%%Common AppData%%\Microsoft\Group Policy"
MOVE /Y "%%Common AppData%%\Microsoft\Search" "Support\Cleanup\%%Common AppData%%\Microsoft\Search"
MOVE /Y "%%Desktop%%\Phoebus Letter Search Tool.url" "Support\Cleanup\%%Desktop%%\Phoebus Letter Search Tool.url"
MOVE /Y "%%drive_C%%\Users" "Support\Cleanup\%%drive_C%%\Users"
MOVE /Y "%%drive_C%%\Temp" "Support\Cleanup\%%drive_C%%\Temp"
MOVE /Y "%%drive_C%%\Logs" "Support\Cleanup\%%drive_C%%\Logs"
MOVE /Y "%%Program Files Common%%\McAfee" "Support\Cleanup\%%Program Files Common%%\McAfee"
MOVE /Y "%%ProgramFilesDir%%\CA" "Support\Cleanup\%%ProgramFilesDir%%\CA"
MOVE /Y "%%ProgramFilesDir%%\McAfee" "Support\Cleanup\%%ProgramFilesDir%%\McAfee"
MOVE /Y "%%ProgramFilesDir%%\Juniper Networks" "Support\Cleanup\%%ProgramFilesDir%%\Juniper Networks"
MOVE /Y "%%ProgramFilesDir%%\RES Software" "Support\Cleanup\%%ProgramFilesDir%%\RES Software"
MOVE /Y "%%SystemRoot%%\rescache" "Support\Cleanup\%%SystemRoot%%\rescache"
MOVE /Y "%%SystemRoot%%\Tasks" "Support\Cleanup\%%SystemRoot%%\Tasks"
MOVE /Y "%%SystemRoot%%\AppCompat" "Support\Cleanup\%%SystemRoot%%\AppCompat"
MOVE /Y "%%SystemRoot%%\winsxs\ManifestCache" "Support\Cleanup\%%SystemRoot%%\winsxs\ManifestCache"
MOVE /Y "%%Cookies%%\*" "Support\Cleanup\%%Cookies%%"
MOVE /Y "%%SystemRoot%%\Logs" "Support\Cleanup\%%SystemRoot%%\Logs"
MOVE /Y "%%SystemRoot%%\ServiceProfiles" "Support\Cleanup\%%SystemRoot%%\ServiceProfiles"
MOVE /Y "%%SystemSystem%%\SMI" "Support\Cleanup\%%SystemSystem%%\SMI"
MOVE /Y "%%SystemSystem%%\Tasks" "Support\Cleanup\%%SystemSystem%%\Tasks"

:: XCopy RES folder and VB Script to correct locations
XCOPY "\\ServerPath\ThinApp\%%Local AppData%%\*" "%%Local AppData%%\" /E /Y
MOVE /Y "%%Local AppData%%\respf.vbs" ".\"

:: print Folder list in cleanup and size
Dir Support\Cleanup > Support\Cleanup\cleanup.log

:: Delete this file after it has completed
DEL Cleanup.bat
0 0 vote
Article Rating
Share this Post
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x