Script to change outlook pst locations

tlman12 used Ask the Experts™
I'm trying to create a vbscript or autoit script that will
a. Retrive an users PST location (i have a simple one that does this)
b. move the pst file from old location to a different location
c. repoint oulook to look for the pst file in the new location.

so far i've only been able to do a. suffesfully all the time, b. successfull part of the time and i haven't figured out c. at all

one of the problems is that this script will have to work with oulook 2002 to outlook 2007 possibly 2010 also windows xp and windows 7

is there a script out there that can do this? or can anyone help me out with it?

heres the code to get the pst files:
#Include <String.au3>
Func GetPathFromStoreID($strStoreID)
	Local $lngLen = "", $str = "", $lngColonPos = "", $final = ""
    For $lngLen = 1 To StringLen($strStoreID) Step 2
        $str = $str & _HexToString(StringMid($strStoreID, $lngLen, 2))
    $str = StringReplace($str, Chr(0), "")
    $lngColonPos = StringInStr($str, ":\")
    If $lngColonPos > 0 Then
		$final = StringRight($str, StringLen($str) - $lngColonPos + 2)
		Return $final

Open in new window

for vbScript
Function GetPathFromStoreID(strStoreID)  
	On Error Resume Next 
	For lngLen = 1 To Len(strStoreID) Step 2 
		str = str & Chr("&h" & Mid(strStoreID, lngLen, 2)) 
	str = Replace(str, Chr(0), vbNullString) 
	lngColonPos = InStr(str, ":\") 
	If lngColonPos > 0 Then 
		GetPathFromStoreID = Right(str, Len(str) - lngColonPos + 2) 
	End If      
End Function

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Not tested but maybe something like this?

#include <String.au3>

$DFT_PROF = RegRead('HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles', 'DefaultProfile')

$NEW_PATH = '<New Path to Outlook PST>\Outlook.pst'
$REG_PATH = StringToBinary($DFT_PATH, 2)

$x = 1

While 1
	$REG_ENUM = RegEnumKey('HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\' & $DFT_PROF, $x)
	If @error <> 0 Then ExitLoop

	$x += 1

	$OLD_PATH = RegRead('HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\' & $DFT_PROF & '\' & $REG_ENUM, '001f6700')
	If $OLD_PATH = '' Then ContinueLoop

	MsgBox(0,'', BinaryToString($OLD_PATH,2))
	;FileCopy(BinaryToString($OLD_PATH,2), $NEW_PATH, 8)
	;RegWrite('HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\' & $DFT_PROF & '\' & $REG_ENUM, '001f6700', 'REG_BINARY', $REG_PATH)

Open in new window


If you need to move PST files and update profile, you can have a look to PSTStation Corporate
If you want to make the job with a script, don't forget to check also "001e6700" for ANSI pst files !

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial