What is the script to remove PST File Profiles from Outlook ?

Updated: 06/25/2015
Article #: 21


You can use the following VBScript in a logon script to remove PST files from the default profile on the computer (if Outlook is closed). If the script runs when Outlook is open, it will remove the PST files from the profile currently in use.
To use, copy the PST File Script to remove PST Profiles from Outlook code below and paste it into Notepad. Save the file with a vbs extension. Double-click on the file to run it, or use it with a logon script to run when the user's log on their computer.
On Error Resume Next
Dim objOutlook 'As Outlook.Application
Dim Stores     'As Outlook.Stores
Dim objFolder  'As Outlook.Folder
Dim i          'As Integer
 
Set objOutlook = CreateObject( "Outlook.Application")
Set Stores = objOutlook.Session.Stores
 
i = 1
Do Until i > Stores.Count
 
     If Stores(i).ExchangeStoreType = 3 Then
        Set objFolder = Stores(i).GetRootFolder
       objOutlook.Session.RemoveStore objFolder
     Else
      i = i + 1
End If
 
Loop






Rate this FAQ:
Rating: 0.00 / Votes: 0