Skip to content

Instantly share code, notes, and snippets.

@rickupton
Last active July 12, 2022 09:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rickupton/16f9a7b445a668c70c61 to your computer and use it in GitHub Desktop.
Save rickupton/16f9a7b445a668c70c61 to your computer and use it in GitHub Desktop.
Automatically compact all Microsoft Outlook PST data files using an AutoIT script
;//Compact all PST files.au3
;//Rick Upton, November 1, 2015
;//http://www.rickupton.com | http://gb.rickupton.com
;//
;//This AutoIT script is a slightly modified version of code posted here: http://superuser.com/questions/836758/bulk-compaction-of-700gb-of-pst-files
;//The purpose of this code is to automatically compact all Outlook PST files on a Windows PC.
;//
;//Using a PowerShell script, open the Mail control panel and then run this script using the following two commands:
;//Show-ControlPanelItem Mail*
;//Start-Process "C:\Compact all PST files.au3" -Wait
;//
#include <GUIListView.au3>
SplashTextOn("Automated compaction of Outlook files in process", "DO NOT TOUCH THE COMPUTER WHILE THIS IS RUNNING.", 400, 80)
Opt("WinTitleMatchMode", 4)
WinWait("Mail Setup - Outlook", "Setup e-mail accounts and dire")
ControlClick("Mail Setup - Outlook", "Setup e-mail accounts and dire", "Button2")
WinWait("Account Settings", "AcctMgr Tab")
;//Gets list of Data files listed
$sTitle = "Account Settings"
$hWnd = WinGetHandle($sTitle)
If @error Then
MsgBox(0, "Error", "Unable to find window")
EndIf
WinActivate($hWnd)
$hlist = ControlGetHandle($hWnd, "", "[CLASS:SysListView32; INSTANCE:2]")
If @error Then Exit
$arraycount = _GUICtrlListView_GetItemCount($hlist)
Local $ltext[$arraycount]
$i = 0
Do
$ltext[$i] = _GUICtrlListView_GetItemText($hlist, $i)
$i = $i + 1
Until $i = $arraycount
;//Goes into each listed Data file and compacts them
$b = 0
Do
_GUICtrlListView_ClickItem($hlist, $b, "left", False, 2)
Sleep(1000)
WinWaitActive("Outlook Data File")
ControlClick("Outlook Data File", "", "[CLASS:Button; INSTANCE:2]") ; click Compact Now
Sleep(1200)
If WinExists("Compact Now") Then WinWaitClose("Compact Now")
WinClose("Outlook Data File")
$b = $b + 1
Until $b = $arraycount
WinClose("Outlook Data Files")
WinClose("Account Settings")
WinClose("Mail Setup - Outlook")
SplashOff()
Exit
@styxadmin
Copy link

Softaken PST Compress software safely reduces the size of large Outlook PST data files by compressing them. It is extremely well designed to compact extra-large Outlook PST data files to avoid any type of corruption and to save space in the hard drive of the system. This application does not alter the contents of Outlook PST files. Compress Outlook PST tool enables a user-friendly GUI appearance with advanced algorithms. This utility supports all MS Outlook and Windows OS versions.

Visit here:- https://www.softakensoftware.com/compact-pst.html

Why don't you bugger off you shill!

@styxadmin
Copy link

Here is another complete tool to compress PST File with multiple different options. Download free PST Compress tool and get rid of the large heavy file in just a few simple steps. For free version visit: https://www.sysinfotools.com/recovery/pst-compress.php

Why don't you sell your software somewhere else!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment