Command Line Options

<< Click to Display Table of Contents >>

Navigation:  Using Scheduled TreeSize Tasks >

Command Line Options

The Professional Edition of TreeSize accepts command line options enabling you to run scheduled scans or to have the results of a scan on your monitor the next morning. The Schedule dialog will help you compile a command line with the options below. Please note: These option are not available in the Personal Edition.

Treesize.exe [/OPTION] SCANPATH

 

/?   or   /HELP

Shows this help page.

/AGEOFFILES

Saves the graph on the "Age of Files" tab of the scanned directory to a bitmap, GIF, PNG, JPEG, Text, or CSV file. The file type depends on the extension of the specified file name. The following example creates a JPEG image file of the"Age of Files" graph for your local drive C:

Treesize /AGEOFFILES "C:\Documents\c_file_ages.jpg" "C:\"

/APPENDTOFILES

If this option is used, TreeSize will append its output to existing files when doing an export, e.g. when using /TEXT.

Please note: This parameter will not work with exported images, XML and PDF files. Those files will be overwritten, except when using the switch /DATE.

/ARCHIVEBITFILESONLY

This option will include only files for which the archive bit set in the scans. This option can be very useful if you want to calculate the size of a backup. In this case, you can create a shortcut on your desktop or in your start menu that will automatically start calculating the size of your backup. Example:

Treesize /ARCHIVEBITFILESONLY "\\Server\Backup\This"

/ATTACH

If specified, all exported files will be attached to the email. If not specified, files with an explicitly given path are not attached. This is useful in case you XML or Excel files are getting quite large and fill up you email account.

This example will export to an Excel file but not attach it to the mail:

TreeSize.exe /EMAIL "treesize@example.com" /EXCEL "C:\Temp\test.xlsx" "F:\"

These examples will attach the Excel file to the email:

TreeSize.exe /EMAIL "treesize@example.com" /EXCEL "F:\"

TreeSize.exe /EMAIL "treesize@example.com" /ATTACH /EXCEL "C:\Temp\test.xlsx" "F:\"

/BARCHART <filename>

Saves the bar chart of the scanned directory to a bitmap, GIF, PNG, or JPEG file. The file type depends on the extension of the specified file name. This example creates a PNG image file of the bar chart for your local drive C:

Treesize /BARCHART "C:\Documents\c.png" "C:\"

/COMPARE <filename|path>

Compares the scanned path with a saved XML report. The following example scans drive C: and compares the result with a saved XML report for this drive:

Treesize /COMPARE "C:\Reports\TreeSize\c.xml.zip" "C:\"

Instead of an XML file, you can also use a path with this command line parameter. The given path will be compared with the current scan result. The following example scans drive C:\ and additionally uses the path D:\Backup_of_C to perform a comparison between the two:

Treesize /COMPARE "D:\Backup_of_C" "C:\"

Alternatively, you can compare two already existing XML reports e.g. "c1.xml.zip" and "c2.xml.zip" by using this command :

Treesize /OPEN "C:\Reports\TreeSize\c1.xml.zip" /COMPARE "C:\Reports\TreeSize\c2.xml.zip"

The /OPEN command prepares the comparison of the two files by expanding the first file ("c1.xml.zip") into a scan file. The second file ("c2.xml.zip") will be compared to this expanded scan file, just like it would happen, if "c2.xml.zip" was compared to a "real" scan.

/COPYTO <path>

This option can only be used in combination with the command line option /SEARCH.
It copies the results of a TreeSize file search to the target location.
The following command will search on your local drive C: using the latest search options and copies the search results to the folder "C:\temp\ObsoleteFiles":

Treesize /SEARCH:Start /MOVETO "C:\temp\ObsoleteFiles" "C:\"

See also: Move checked files

/CREATEDPASTDAYSONLY <n>

This option will include only files in the scans, which were created during the number of days entered in the argument. In the following example, this option will only include only files created during the last eight days in the scan:

Treesize /CREATEDPASTDAYSONLY 8

It corresponds to the option "Include only files created in the past X days" in the Options dialog.

/CREATESNAPSHOT <drive>

Creates a snapshot for the drives that are given after this command line paramter. Example:

Treesize /CREATESNAPSHOT "C:\" "D:\"

Creating snapshots may require administrative privileges.

/DATE

This switch will add the current date and time to all export file names in the command line. This is useful if you want to do scans regularly, e.g. every night or every weekend. The following example will scan the network path "\\Host\Share" and save the result to a file like "C:\Scans\name_2013-08-14_17-18-24.xls":

Treesize /DATE /EXCEL "C:\Scans\name.xls" "\\Host\Share"

/DEDUPLICATE

This option can only be used in combination with the command line option /SEARCH.
It will replace the duplicate files that were found by the TreeSize duplicate file search with NTFS hardlinks:

Treesize /SEARCH:Start /DEDUPLICATE "C:\"

/EMAIL <recipient>

Sends the collected data to the given email address. This parameter can be used only once on the command line, and only one email with all results will be sent. Multiple recipients can be separated with semicolons (;) or commas. To send emails via the command line, you need to specify valid SMTP settings on the corresponding page in the TreeSize options dialog. Example:

Treesize /EMAIL treesize@example.com "\\SERVER\C$"

If no other parameters have been specified, the email will be sent in the format that is set in the options (HTML or plain text). If you would like to define the format independent from the current options, you can use the parameters /TEXT or /HTML right behind the definition of the recipient address(es). Example:

Treesize /EMAIL treesize@example.com /TEXT "\\Server\Share"

By combining parameters you can also add attachments to the email. The following example will add an Excel report of the scan as an attachment to the email:

Treesize /EMAIL treesize@example.com /EXCEL "\\Server\Share"

/EMAILIFRESULTSFOUND

This option can only be used in combination with the command line options /SEARCH and /EMAIL. If this parameter is specified, TreeSize will only send an email with the current search results, if at least one file or folder has been found during the search, by any of the specified search types.

/EMPTYRECYCLEBIN

If you use this option, TreeSize will empty the recycle bin before running the current scan. Example:

Treesize /EMPTYRECYCLEBIN "C:\"

/EXCEL <filename>

Exports the collected data in Microsoft Excel format and saves it under the entered file name. Supported formats are the conventional .XLS file format (Excel 97-2003) as well as the .XLSX format (introduced with Excel 2007). The used format depends on the extension of the specified file name. The application will terminate itself after saving. Example:

Treesize /EXCEL "C:\Documents\c.xls" "C:\"

If the file name already exists, the file will be opened and a new worksheet will be added.

Please note: In the TreeSize File Search (/SEARCH) the results of each search type are collected in their own specific worksheet. If the file under the given path already exists, these sheets will be overwritten. To prevent this, you need to use the command line option /APPENDTOFILES.

/EXCLUDE <pattern1;pattern2>

This option enables you to specify patterns for files and folders that should be excluded from a scan. Multiple exclude patterns can be separated using a semicolon (;). If one or more of the patterns contain spaces, the complete pattern string must be set into quotes ("). The following example will ignore files and folders that end with ".tmp" or where the exact name is "system":

Treesize /EXCLUDE "*.tmp;system" "\\Server\Users"

/EXPAND <level|size>

This option lets you specify how many levels in the directory tree will be expanded after scanning. If you don't specify a number after this option, all folders will be expanded. Instead of a directory level you can also indicate an amount in Mega Byte (MB). In this case all folders larger than the given amount will be expanded. The unit "MB" must follow the number without a blank. The following example will scan the folder "H:\User", expand all folders larger than 10 MB and save the result to the Excel file "C:\Results\Allusers.xlsx":

Treesize /EXCEL "C:\Results\Allusers.xlsx" /EXPAND 10MB "H:\User"

/EXPANDABLEREPORT

If this option is used, Excel exports will use expandable/collapsible groups that can be navigated similar to the directory tree.

/EXPORTDRIVESLIST <filename>

This option enables you to export the contents of the "Drive List" to an Excel, Text, or CSV file. The file type depends on the extension of the specified file name. Example:

Treesize /EXPORTDRIVESLIST "C:\Results\AllDrives.csv"

/EXPORTFILES

If specified, files will be included in all exports. So this option is equivalent to activating the option "Tools > Options > Export > * > Exported elements > Include single files in export"

/EXPORTGROUPSEXPANDED

if specified, the export of the extensions list will contain all information about the extensions contained within groups.

/EXPORTPATHSLIST <filename>

This option can only be used in combination with the command line option /SEARCH.

Exports a simple list that contains all search results. The list will contain only the full paths of the search results and no other information. Supported formats for the destination file are .txt and .csv.

This example will search for, and create a list of all exe files on drive C:

Treesize /SEARCH:Start /FILTER "*.exe" /EXPORTPATHSLIST "C:\Results\SearchResults.csv" "C:\"

It can be used to import results of a previous search back into the user interface, by using "File > List of paths > Import path list", or the parameter /IMPORT.

If the option "Tools > Options > Export > Include duplicate groups" is activated, you can also use this function to export and import results of the duplicate search including their group structure.

/EXTENSIONSLIST <filename>

This option enables you to save the statistics on file extensions / file types of the scanned file system branch to an Excel, HTML, Text, or CSV file. The file type depends on the extension of the specified file name. The exported columns will be those that were enabled in the user interface on the tab "Extensions" when it was last used, or at the time when the configuration file supplied via /OPTIONS was written.

The following example scans drive C: and creates an Excel file named "D:\TreeSize Reports\C_filetypes.xls" with the statistics of the file types on this drive:

Treesize /EXTENSIONSLIST "D:\TreeSize Reports\C_filetypes.xls" "C:\"

/EXTENSIONSCHART <filename>

Saves the small graph shown on the bottom of the "Extensions" page to an image file (bitmap, GIF, PNG, or JPEG).

/EXTENSIONSPIECHART <filename>

Saves a piechart that shows the distribution of "file extensions" to an image file (bitmap, GIF, PNG, or JPEG).

/FILTER <pattern1;pattern2>

Sets a file filter counting only files with certain extensions, e.g. ".mp3" or ".doc". Multiple patterns may be passed, separated by semicolon (;). The following example will search for MP3 and AVI files in the "Users" directory on the server:

Treesize /EXCEL "C:\Results\UsersMediaFiles.xlsx" /FILTER "*.mp3;*.avi" "\\Server\Users"

When performing a TreeSize File Search (/SEARCH), you can also use the /FILTER command line switch to specify the patterns of the Custom File Search. To perform a more complex custom file search you should save the search options to a file and pass the resulting XML file to the command line after /SEARCH.

/FOLLOWREPARSEPOINTS

If this switch is added to the command line, TreeSize will follow mount points and external symbolic links when scanning a file system tree.

/GROUPSCANS

Using this command line switch will group all scanned directories under a virtual root folder. Use /GROUPSCANS FALSE if you want to ensure that no virtual root folder is used.

/HIDESMALLFOLDERS <value>

Allows to hide objects that are smaller than a minimum size, which is useful for getting clear exports. <value> can be a size value with unit, or a plain byte value without unit. Cannot be used in combination wih /EXPAND. In this example only folders having a minimum size of 50MB will be exported:

TreeSize /HIDESMALLFOLDERS 50MB /EXCEL "C:\Results\DriveC.xlsx" C:\

/HISTORYCHART <filename>

Saves the graph on the "History" tab of the scanned directory to a bitmap, GIF, PNG, or JPEG file. The file type depends on the extension of the specified file name. This example creates a JPEG image of the history graph for drive C:

Treesize /HISTORYCHART "C:\Documents\c_history.jpg" "C:\"

/HTML <filename>

Saves the collected data to a HTML file which can be viewed with any HTML browser. You can specify which information of the scan will be included in the export via "Home > Options > Export > HTML > Charts and lists to include. You can select which of the additional lists, or charts should be added to the export. They will automatically be embedded into the HTML file that is generated after the scan.

The following example will generate an HTML report for the drive C: and save it to "D:\HTML":

Treesize /HTML "D:\HTML\treesize.html" "C:\"

If you would like to scan and export multiple drives or folders, we recommend either using one call for each drive or folder or using the command line option presented in the following example:

Treesize /HTML "D:\HTML\drive-c.html" "C:\" /HTML "D:\HTML\drive-d.html" "D:\"

If you want more than one scan to be part of the HTML file, you should add the command line switch /GROUPSCANS. When exporting to HTML without an included image, you could alternatively us the switch /APPENDTOFILES.Without one of these flags, the HTML file will get overwritten.

/IMPORT <filename>

This option can only be used in combination with the command line option /SEARCH.

Loads a list of paths into the user interface of the TreeSize file search. The file can be in .txt, or .csv format. This parameter can be used to import results of a previous search. The imported files and folders can be moved/copied/deleted/archived, like any "live" search result, using the file operation dialog.

Example:

Treesize /SEARCH /IMPORT "C:\Results\filelist.txt"

You can also combine this parameter with the parameter /MOVETO, to automatically move or delete the files that are contained in the text file. Example:

Treesize /SEARCH /IMPORT "C:\Results\filesToDelete.csv" /MOVETO "Recycle Bin"

/LISTSEPARATOR <separator char>

Enables you to define the separator used when exporting text or CSV files. Text files use the tabulator by default, CSV-files the list separator from the regional settings of the Windows control panel. Please specify a single character or the string "TAB" for tabulator after this switch. Examples:

Treesize /LISTSEPARATOR ; /TEXT "C:\Results\c.txt" "C:\"

Treesize /LISTSEPARATOR TAB /TEXT "C:\Results\c.csv" "C:\"

/MOVETO <path|zip file|"Recycle Bin"|executable>

This option can only be used in combination with the command line option /SEARCH.
It moves the results of a TreeSize file search to another location, ZIP file, the recycle bin, or passes them to an executable file as parameter. To move the files to the recycle bin, specify the name of the recycle bin (as seen in the Windows Explorer) or "Recycle Bin" after the /MOVETO option.
The following command will search on your local drive C: using the latest search options and moves the search results to a ZIP file called "ObsoleteFiles.zip":

Treesize /SEARCH:Start /MOVETO "C:\temp\ObsoleteFiles.zip" "C:\"

This call moves the search results to your system recycle bin instead:

Treesize /SEARCH:Start /MOVETO "Recycle Bin" "C:\"

This example will load saved search options with the file name "SearchOptions.xml" and move all files that were found to the path "E:\Obsolete Files":

Treesize /SEARCH:Start /MOVETO "E:\Obsolete Files" "SearchOptions.xml"

This example uses the same search options, but instead of moving the files it will pass the full file path to your batch file "Archiver.bat". This batch file may e.g. trigger an archiving process for the passed files:

Treesize /SEARCH:Start /NOGUI /MOVETO "Archiver.bat" "SearchOptions.xml"

For ZIP files the /DATE parameter can be used to add the current date and time to the ZIP file name.

See also: Move checked files

/NOGUI

No window will be shown and the application will not appear in the task bar. Useful to execute scans or searches in background, without visual feedback.

Caution: Use this switch only if you have tested the rest of the command line options because error messages cannot be displayed in this mode.
However, errors will be logged in the Windows event log.

/NOHEADERS

Omits the header lines usually written on top of scan or search export files. This makes it easier to receive plain data for postprocessing.

/NOUNITS

Omits the units usually written after size values. This option in combination with /SIZEUNIT 0 will export plain byte values. This makes it easier to receive plain data for postprocessing.

Please note: This command line will only effect exports of the directory tree, generated by using the /TEXT, /EXCEL, /HTML, /EMAIL, or /PRINT options. /EXTENSIONSLIST, /USERSLIST, /EXPORTDRIVESLIST, or /TOPFILESLIST will not be effected.

/OPEN <filename>

Opens a saved XML report on application start. Example:

Treesize /OPEN "C:\Reports\Drive_C.xml.zip"

/OPTIONS <filename>

Use this parameter to apply exported user settings to TreeSize. User settings can be exported at "File > Options > Export". Example:

Treesize /OPTIONS "C:\Temp\User Settings.xml"

Hint: Change as many settings a possible in the user interface before saving the options to reduce the amount of command line parameters you need.

/PDF

Saves the results to a PDF file after the scan or search is finished. The application will terminate itself after saving. The following example will execute a scan of your local drive C: and save the results to a PDF file:

Treesize /PDF "C:\Results\C_scan.pdf" "C:\"

/PIECHART <filename>

Saves the pie chart of the scanned directory to a bitmap, GIF, PNG, or JPEG file. The file type depends on the extension of the specified file name. The following example will scan the drives C: and D: and exports a pie chart for each one in PNG format:

Treesize /PIECHART "C:\Reports\C_pie.png" "C:\" /PIECHART "C:\Reports\D_pie.png" "D:\"

/PRINT

Prints a report for the scanned directory tree using default printer configured in your system settings. The application will be terminated after printing. Example:

Treesize /PRINT "\\SERVER\USERS"

/RESTRICTED

Starts TreeSize in a restricted mode in which many features are disabled that are not of interest for "normal" (non-admin) users. Among the disabled features are: Check for Update, Open Software applet of Windows Control Panel, Schedule TreeSize scans, connect network drive, configure Windows System Restore, Run as administrator, exports, and apply NTFS compression. You can supply a path that should be scanned, e.g. the user's home directory, at the command line or using the Startup Paths in a saved configuration file. If you additionally pass the command line option /READONLY, the user won't be able to delete or move files in TreeSize, so it will be usable as reporting tool only.

/SCAN <filename>

Scans all paths that are found in the text file specified after this switch. The text file must contain one path per line. The following example scans all paths that are found in the file "D:\PathsToScan.txt" and writes each scan result to a separate sheet in an Excel File with today's date:

Treesize /EXCEL "D:\Results\%DATE%.xlsx" /SCAN "D:\PathsToScan.txt"

You may also call TreeSize in a "for" loop with one of the paths only, please find an example below.

/SEARCH[:<Start|Internet>]

Opens the File Search window of TreeSize. If ":Start" is added to this command line option, the search is started immediately with the last settings. A previously saved XML file containing search settings may be passed, these settings will then be used to perform the search. Please note that files which are found in this search are automatically checked. The following example performs the search with settings that have previously been saved to the file "SearchSettings.xml" and saves the results to at text file:

Treesize /SEARCH:Start /TEXT "T:\SearchResult.txt" "SearchSettings.xml"

If ":Internet" is added to this command line option, it will start searching for temporary internet files. The drives activated during the last regular scan will be scanned, a special set of drives and paths can be specified on the command line (separated with blanks). Example:

Treesize /SEARCH:Internet "C:\"

Hint: In general, the last search settings or a former saved set of search settings will be used. However, you can specify the search patterns for the custom search using the /FILTER command line option.

/SHEETNAME <title>

Enables you to specify the name of the sheet that will be added to an Excel file when using the /EXCEL command line switch. Please note that an Excel sheet name must be unique in an Excel file and certain special characters like slashes, backslashes and colons are forbidden. TreeSize will always create a unique sheet name by replacing invalid character with underscores and by adding date and time if necessary.

/SHORTDATEFORMAT <format>

Alters the short date format for this process, which can be configured in the regional options of the Windows Control Panel. Exports of TreeSize will use this format for date values.  Example:

Treesize /SHORTDATEFORMAT YYYY-MM-DD /TEXT "D:\export.txt" "E:\"

/SIZEUNIT <n>

This option can be used to specify the unit to be used for displaying size values: N can have the values 0 to 5 which mean: 0 = Bytes, 1 = KB, 2 = MB, 3 = GB, 4 = TB, 5 = Automatic Units. Without this option the last used configuration in TreeSize will be used.

/SORTBY <ColumnName>

Enables you to specify by which value the generated exports will be sorted. Possible values are column names like "Size" or "Name". The last used sort type in the TreeSize user interface will be used by default. Example:

Treesize /SORTBY Size /TEXT "D:\export.txt" "E:\"

Treesize /SORTBY Name /EXCEL "D:\export.xlsx" "E:\"

/SUBJECT <subject>

This option allows you to customize the subject that will be used for emails that are sent at the end of the scan. Example:

Treesize /EMAIL treesize@example.com /SUBJECT "TreeSize Professional Scan Report" "\\Server\Share"

/TEXT <filename>

Saves the results to a text or CSV file after the scan or search is finished. The application will terminate itself after saving. The following example will execute a scan of your local drive C: and save the results to a text file:

Treesize /TEXT "C:\Results\C_scan.txt" "C:\"

This example will save the results of a File Search on your local drive C: with the last search configurations to a CSV file:

Treesize /SEARCH:Start /TEXT "C:\Results\C_search.csv" "C:\"

/TITLE <title>

Can be used to change the scan title in a printed report or exported file. This allows you to supply additional information to the user when using TreeSize in an automated environment. The use of environment variables is allowed. Example:

Treesize /TITLE "This is drive C on Server3" /PRINT "\\Server3\C$"

The title will be applied only to scans which appear after this options on the command line. Multiple /TITLE flags are allowed to apply separate titles to different scans.

/TOPFILESLIST <filename>

This option enables you to save the contents of the Top 100 list to an Excel, HTML, Text, or CSV file. The file type depends on the extension of the specified file name. Example:

Treesize /TOPFILESLIST "C:\Temp\C_top_files.txt" "C:\"

/TREEMAP <filename>

Saves the treemap of the scanned directory tree as bitmap, GIF, PNG or JPEG file. The file type depends on the extension of the specified file name. Example:

Treesize /TREEMAP "C:\Dokumente\treemap.jpg" "C:\"

/USERSLIST <filename>

This option enables you to save the statistics showing the results grouped by username to an Excel, HTML, Text, or CSV file. The file type depends on the extension of the specified file name. The exported columns will be those that were enabled in the user interface on the tab "Users" when it was last used, or at the time when the configuration file supplied via /OPTIONS was written.

The following example scans drive C: and creates an Excel file in "C:\Temp" with the statistics of the users on this drive:

Treesize /USERSLIST "C:\temp\C_users.xls" "C:\"

/USERNAME <username>

Specifies the username that should be used to authenticate for the scans. Use /PASSWORD to specify a password for this username. It is recommended to instead use the Microsoft tool RUNAS.

/USERFILTER <username>

With this option only files owned by a certain user will be taken into account when scanning. Provide the name of this user after this switch. Please note that you cannot use multiple user names here, but the  wildcards "*" and "?" are supported. Example:

Treesize /USERFILTER miller "\\Server\GroupDrive"

/USERSCHART <filename>

Saves the small graph shown on the bottom of the "Users" page to an image file (bitmap, GIF, PNG, or JPEG).

/USERSPIECHART <filename>

Saves a pie chart that shows the "user statistics" of the current scan to an image file (bitmap, GIF, PNG, or JPEG).

/VIEWTYPE n

Defines on which values the "Percent of Parent", the "Growth" columns and the "Age of Files" chart are based. Possible value are:

2: Size
3: Allocated Space (Size on disk)
7: Number of Files

/XML <filename>

Saves the scan results to a XML file that can be loaded for comparisons at a later date. Example:

Treesize /XML "C:\Results\Allusers.xml.zip" "H:\users\"

This option can be combined with the /EXPAND switch to limit the exported directories.
Please note: When loading a limited XML export to TreeSize, you cannot navigate though the complete directory branch, but only the exported directories.

SCANPATH

At the end of the command line, you may pass one or more paths that should be scanned by TreeSize.
Several paths are separated using a blank. Paths containing a blank has to be quoted ("). Example:

Treesize "C:\Program Files\" "C:\Windows"
 
The wildcards "*" and "?" are allowed. Example:

Treesize "H:\users\A*"

To start one instance for each folder, you may use the Windows "for" command like this:

for /D %i in (H:\Users\A*) do @start /w Treesize.exe %i

In case an error occurs, it will be returned as Windows error code in the exit code of the process. Environment variables (e.g. %APPDATA%) can be used In filenames for the export as well as in the scanned paths.

Scanning Multiple Directories

If you need to scan multiple directories, it might be a good idea to merge several calls in a Batch file, for example:

START /WAIT "TreeSize" "C:\Program Files\JAM Software\TreeSize Professional\Treesize.exe" /EXCEL "D:\Share1.xls" "\\Server\Share1"

START /WAIT "TreeSize" "C:\Program Files\JAM Software\TreeSize Professional\Treesize.exe" /EXCEL "D:\Share2.xls" "\\Server\Share2"

START /WAIT "TreeSize" "C:\Program Files\JAM Software\TreeSize Professional\Treesize.exe" /EXCEL "D:\Share3.xls" "\\Server\Share3"

The command "START /WAIT" ensures that the jobs start sequentially. Not starting the jobs parallel is usually better because a single job takes more advantage from caches and system resources. It is also possible to store the shares that should be scanned in a text file and use the Windows "for" command like this:

FOR /F %%p IN (Paths.txt) DO START /WAIT Treesize.exe /EXCEL "c:\temp\TreeSize-Reports-%DATE%.xls" "%%p"

FOR /F "tokens=1" %%i IN (Shares.txt) DO START /WAIT Treesize.exe /EXCEL "c:\temp\%%i.xls" "\\Server\%%i"

Please note: The double percent characters are required in batch files, on the command line use a single percent only.

Scheduled Start

You can use the Windows Scheduled Tasks to run TreeSize with certain command line options daily, weekly, or monthly at a certain time. The "Schedule Dialog" of TreeSize will help you setting up a scheduled task.

You can also use the "SCHTASKS" command to perform scheduled scans. If you, for example, want to scan the drives C: and E: next night at 03:00 a.m. and save the results to an Excel file, you could use the following command line:

SCHTASKS /Create /SC DAILY /ST 03:00 /TN TreeSizeScan /TR "'C:\Program Files\JAM Software\TreeSize\Treesize.exe' /EXCEL C:\Temp\tsp.xls /EXPAND 2 C:\ E:\"

Get help about the "SCHTASKS" command on Microsoft's pages or by typing:

SCHTAKS /Create /?

Please note: Error messages occurring during scheduled scans are listed in the systems Windows event log.

PowerShell

Windows PowerShell can be useful in combination with TreeSize. This example shows how to search a couple of remote computers that are queried using an LDAP query in the Active Directory (AD):

$computer = Get-ADComputer -SearchBase "ou=client computers,ou=intranet,dc=intranet,dc=jam-software,dc=com" -Filter *
foreach ($comp in $computer.name)
{
   $path = "\\$comp\C$\Windows"
   Add-Content Scan.txt "$path"
}
#debug
Get-Content -Path Scan.txt
# start TreeSize with the collected paths
&"C:\Program Files\JAM Software\TreeSize Professional\Treesize.exe" /SEARCH:Start /SCAN Scan.txt /FILTER *.exe /Export FoundFiles.txt

Windows Scripting Host

If you intend to use the Windows Scripting Host (WSH), your command to start TreeSize will look like:

Set Shell = CreateObject("WScript.Shell")
Shell.Run """C:\Program Files\TreeSize Professional\Treesize.exe"" /XML ""C:\Reports\drive_c.xml.zip"" ""C:\"""

Exit Codes

If the operation was completed successfully, the exit code is 0. If an error occurred TreeSize will return a Windows error code as exit code if available, or 1 to indicate a general error. In any case the Windows Event Log will contain further information in the "Application" log, Event Source "TreeSize".