'############################################################################### '# Remove PST from Outlook '# Uses Outlook to remove PST Files from Profile '# 29.10.2011 Andres Bohren / www.icewolf.ch '############################################################################### Option Explicit ListPST ShowIdentity Dim oWshShell Set oWshShell = WScript.CreateObject("WScript.Shell") 'oWshShell.Popup "Removed PST Files from your Profile", 2, "RemovePST", 64 Public Sub ListPST() 'On Error resume next Dim objOutlook 'As Outlook.Application Dim Session 'As Outlook.NameSpace Dim Store 'As Outlook.Store Dim Stores 'As Outlook.Stores Dim objFolder 'As Outlook.Folder Dim Report 'As String Dim strPrompt 'As String Set objOutlook = CreateObject("Outlook.Application") Set Session = objOutlook.Session 'Set Session2 = objOutlook.Session Set Stores = Session.Stores For Each Store In Stores If Store.ExchangeStoreType = 3 then Report = "" Report = Report & Store.DisplayName & vbCrLf Report = Report & "Location : " & Store.FilePath & vbCrLf Report = Report & "Is Cached Exchange : " & Store.IsCachedExchange & vbCrLf Report = Report & "Is Data File Store : " & Store.IsDataFileStore & vbCrLf Report = Report & "Is Instant Search Enabled : " & Store.IsInstantSearchEnabled & vbCrLf Report = Report & "Is Open : " & Store.IsOpen & vbCrLf Report = Report & "Class : " & Store.Class & vbCrLf Report = Report & "Exchange Store Type : " & Store.ExchangeStoreType & vbCrLf Report = Report & "Store ID : " & Store.StoreID & vbCrLf & vbCrLf msgbox "Report: " & Report set objfolder = nothing Set objFolder = store.GetRootFolder strPrompt = "Remove PST file? " & Store.DisplayName & vbcrlf & Store.FilePath & vbcrlf & "Folder: " & objFolder If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then Session.RemoveStore objFolder End If End If Next End Sub Sub ShowIdentity Dim WshNetwork Set WshNetwork = WScript.CreateObject("WScript.Network") Msgbox "Hostname: " & WshNetwork.ComputerName & " User: " & WshNetwork.UserDomain & "\" & WshNetwork.UserName End sub