ZacUSNYR

PST File Location

45 posts in this topic

#1 ·  Posted (edited)

Found numerous ways to do this and found a VB script that did it using COM Objects so I duplicated it in AutoIt. I'm going to mess around with pulling the information out of HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles but this appears to work well.

#include <Array.au3>

$asPSTPath = _GetPSTPath()

If IsArray($asPSTPath) Then _ArrayDisplay($asPSTPath)

Func _GetPSTPath()
    Local $sFolderSubString, $sPath, $asPathSearch, $sReturn
    Local $oOutlook = ObjCreate("Outlook.Application")
    Local $oNS = $oOutlook.GetNamespace("MAPI")

    If IsObj($oNS) Then
        For $objFolder In $oNS.Folders
            $sPath = ""
            For $i = 1 To StringLen($objFolder.StoreID) Step 2
                $sFolderSubString = StringMid($objFolder.StoreID, $i, 2)
                If $sFolderSubString <> "00" Then $sPath &= Chr(Dec($sFolderSubString))
            Next

            $asPathSearch = StringRegExp($sPath, "(?i)\w(:\\|\\\\)\w.*[pst]", 2)

            If IsArray($asPathSearch) Then $sReturn &= $asPathSearch[0] & Chr(28)
        Next
        Return StringSplit(StringTrimRight($sReturn, 1), Chr(28))
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc   ;==>_GetPSTPath

Of course, use at your own risk. Very limited in testing. It worked every time I tried it on XP machines running Outlook 2003.

The function returns an Array with the locations.

Edited by ZacUSNYR

Share this post


Link to post
Share on other sites



Like that approch.

in case anyone wants it, here is a snipit of code i wrote some time ago that pulls the info from the registry and returns an array of actively used PST's

The code is pretty messy but works for me. use at your own risk.

;find all active PST'S
$DefaultProfile = RegRead ( "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" , "DefaultProfile")

$xBin = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" & $DefaultProfile & "\0a0d020000000000c000000000000046", "1102044e")
$sBinaryToString = BinaryToString(StringRegExpReplace($xBin, '\G(?i)[01][[:xdigit:]]|7f|(..)', '\1'))
$sAllPSTsPath = StringTrimLeft($sBinaryToString, StringInStr($sBinaryToString, '\', 0)-3)
$sAllPSTsPath = StringReplace ($sAllPSTsPath , "8¡»å¡»+*VÂmspst.dllNITAù¿¸ª7Ùn" , @CRLF)
$ActivePSTs = _StringExplode($sAllPSTsPath, @CRLF)

_ArrayDisplay($ActivePSTs, "StringExplode 0")

Share this post


Link to post
Share on other sites

Yea you'd have to do a ton of reading through the registry, plus outlook likes to keep imported, no longer used PSTs in keys as well.

I dig the SRER conversion though. Thanks for posting that.

Share this post


Link to post
Share on other sites

Nice script thanks for sharing. I ran your script and I got the following error:

C:\Temp\New AutoIt v3 Script (3).au3 (23) : ==> Subscript used with non-Array variable.:

$return &= $pathsearch[0] & Chr(28)

$return &= $pathsearch^ ERROR

Fixed by changing

$return &= $pathsearch[0] & Chr(28)

To

If IsArray($pathsearch) Then $return &= $pathsearch[0] & Chr(28)


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hmm you're failing the check for the PST file? Wonder what you're getting back.

Edited by ZacUSNYR

Share this post


Link to post
Share on other sites

Thanks Danny for trying that out. I updated the first post.

Share this post


Link to post
Share on other sites

I just ran this on an XP machine running Office 2007, and it works with that as well. Nice job as I sometimes have to reimage computers at work and would like to know I haven't missed any pst files hidden somewhere non-standard.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Sorry to revive such an old thread, but I need a method similar to the one posted by CarlMontgomery above (parsing the registry) to get a list of the active PST files. Unless there is another way to get a list of PST files that a user that is not currently logged in is using, then parsing the registry is the only option I know of. The problem is that his code is only returning one active PST file, and not any others. Does anyone have any thoughts on this, or know of any other way to get the list of PST files that are actually used by each user account?

Share this post


Link to post
Share on other sites

Please have a look at my OutlookEX UDF.

Which version of Outlook do you run? Then I can tell you which function to use.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

You could search the hard drive for PST files, other than that, you have to check the registry of the user (HKCU) to see what files Outlook is using for that user.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Water,

We run Outlook 2007, 2010, and 2013 (in the testing phases anyway; our users do not have 2013). I looked at your OutlookEX UDF, but correct me if I'm wrong... doesn't it require Outlook to be running? Here's what I'm needing, specifically:

1) For each user on the computer, a list of the PST files added to the default Outlook profile

2) For each user on the computer, a list of the accounts added to that profile

3) For each user on the computer, a list of "additional mailboxes," or shared mailboxes (In Account Settings -> Account -> More Settings -> Advanced)

As always, thank you for the help.

@BrewManNH - I know that the registry entries for Outlook are at HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\[Profile]... but I don't know where to look from there. All of the keys from that point on are in hex, and I'm not sure what exactly to look for from there.

Edited by chaoticyeshua

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Outlook 2007 and later is fine.

If Outlook isn't running _OL_Open starts Outlook in the background, _OL_Close will shut it down when finished.

Run _OL_AccountGet to get a list of all accounts of the default profile.

Run _OL_PSTGet to get a list of all accessed PST files.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Will it get me that info for a user account that isn't logged in? Meaning, if I log into the computer as myself and run it, can I get that information from someone else's user account?

Share this post


Link to post
Share on other sites

The OutlookEX UDF works fine for a logged on user.

To get this information for all users ever logged on to a computer I fear you need to search through the registry.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

That's what I was afraid of, and is what I'd like to do unfortunately. Can anyone point me in the right direction? It looks like the code snippet from CarlMontgomery works, but unfortunately as I said, only gives me one of the PST files that are added. I also don't know how to find the other accounts that are added, or the list of shared mailboxes either...

Share this post


Link to post
Share on other sites

Another question: Why do you need to know the settings for users not logged on at the moment? Can't you wait until they log on and then collect the needed information?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I do desktop support, and it's for a backup script I'm making that will backup data for users that may or may not be present at the time of the backup. The idea is we back up each user account to an external hard drive, re-image the machine, then restore the data after they log in. Getting a list of PST files and other info is something I would "like" to do, but isn't necessary. I'm trying to make it as comprehensive as possible, mainly because our student workers forget to either back up or restore specific things, and if I had a list of stuff for them to do already generated, it'd be pretty hard for them not to do so.

Edited by chaoticyeshua

Share this post


Link to post
Share on other sites

If you have a look at the files of the OutlookEX.ZIP file you'll find _OL_ConfigBackup.au3.

It's a sceleton of a backup function to save all Outlook files and registry keys. Maybe a good starting point.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks! I'll take a look.

Share this post


Link to post
Share on other sites

I think backing up the PST files on the drive would be sufficient for part of this procedure. If you use XCopy or RoboCopy you can have it save the full path it pulls the file from if set correctly. This link might help you with backing up the rest of the files needed.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now