![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Script to launch a MSGBOX listing PST file locations for a logged onuser I've been looking for something like this for a while and decided to put it together. This works when logged on as the interactive user and requires that he/she have an Outlook profile created. This script pops up a MSGBOX with a formatted list of PST files that your average user can understand as shown below: < begin example results > Logged on user is: USERNAME The PST files listed in your Outlook profile are at the locations shown below: ------------------------------------------------------------------------------------ The folder named: Mail Archived to H drive is in this file: H:\MAIL\Personal Folders.pst Date created: 7/8/2008 12:15:33 PM Date last accessed: 1/28/2009 9:09:25 PM Date last modified: 1/28/2009 9:09:25 PM File Size: 291665 KB ------------------------------------------------------------------------------------ The folder named: Archive Folders is in this file: C:\Documents and Settings\USERNAME\Desktop \mailbox.pst Date created: 7/22/2008 1:52:28 PM Date last accessed: 1/28/2009 8:44:32 PM Date last modified: 1/28/2009 8:44:26 PM File Size: 3985 KB ------------------------------------------------------------------------------------ < end example results > This can also be used in an SMTP CDO script to e-mail a user his/her PST configuration via a login script or write the results to a text file or any number of things with a little tweaking... Enjoy... Jim H. Code starts here: on error resume next Set objOutlook = CreateObject("Outlook.Application.11") ' Opens Outlook object Set objNS = objOutlook.GetNamespace("MAPI") ' Specifies MAPI namespace in the Outlook object Set objFSO = CreateObject("Scripting.FileSystemObject") ' used to get file system data for PST files Set WshNetwork = WScript.CreateObject("WScript.Network") ' Used to get logged on user name user = ucase(WshNetwork.UserName) For Each objFolder In objNS.Folders if GetPSTPath(objFolder.StoreID) <> "" then ' You should only return items with a StoreID value pstfiles = GetPSTPath(objFolder.StoreID) Set objFile = objFSO.GetFile(pstfiles) filename = "The folder named: " & vbtab & vbtab & objFolder.name & vbcrlf & _ "is in this file:" & vbtab & GetPSTPath(objFolder.StoreID) & _ vbcrlf & vbcrlf & "Date created: " & objFile.DateCreated & vbcrlf & _ "Date last accessed: " & objFile.DateLastAccessed & vbcrlf & _ "Date last modified: " & objFile.DateLastModified & vbcrlf & _ "File Size: " & objFile.Size / 1024 & " KB" & vbcrlf & vbcrlf & _ "------------------------------------------------------------------------------------" ' The next line allows for the filelist variable to get multiple iterations of the PST value(s) before displaying the MSGBOX filelist = filelist & filename & VbCrLf & VBCRLF end if Next if filelist = "" then filelist = " NO PERSONAL FOLDERS FILES FOUND IN THE CURRENT PROFILE " end if msgbox "Logged on user is: " & user & vbcrlf & vbcrlf & _ "The PST files listed in your Outlook profile are at the locations shown below: " & _ vbcrlf & vbcrlf & "------------------------------------------------------------------------------------" & _ vbcrlf & vbcrlf & filelist Function GetPSTPath(input) For i = 1 To Len(input) Step 2 strSubString = Mid(input,i,2) If Not strSubString = "00" Then strPath = strPath & ChrW("&H" & strSubString) End If Next Select Case True Case InStr(strPath,":\") > 0 GetPSTPath = Mid(strPath,InStr(strPath,":\")-1) Case InStr(strPath,"\\") > 0 GetPSTPath = Mid(strPath,InStr(strPath,"\\")) End Select End Function |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Script to launch a MSGBOX listing PST file locations for a loggedon user On Jan 28, 9:50*pm, BigDaddyJim <hungerfo...@xxxxxx> wrote: Quote: > I've been looking for something like this for a while and decided to > put it together. *This works when logged on as the interactive user > and requires that he/she have an Outlook profile created. > > This script pops up a MSGBOX with a formatted list of PST files that > your average user can understand as shown below: > > < begin example results > > > Logged on user is: USERNAME > > The PST files listed in your Outlook profile are at the locations > shown below: > > ---------------------------------------------------------------------------*--------- > > The folder named: * * * * * * * Mail Archived to H drive > is in this file: * * * *H:\MAIL\Personal Folders.pst > > Date created: 7/8/2008 12:15:33 PM > Date last accessed: 1/28/2009 9:09:25 PM > Date last modified: 1/28/2009 9:09:25 PM > File Size: 291665 KB > > ---------------------------------------------------------------------------*--------- > > The folder named: * * * * * * * Archive Folders > is in this file: * * * *C:\Documents and Settings\USERNAME\Desktop > \mailbox.pst > > Date created: 7/22/2008 1:52:28 PM > Date last accessed: 1/28/2009 8:44:32 PM > Date last modified: 1/28/2009 8:44:26 PM > File Size: 3985 KB > > ---------------------------------------------------------------------------*--------- > > < end example results > > > This can also be used in an SMTP CDO script to e-mail a user his/her > PST configuration via a login script or write the results to a text > file or any number of things with a little tweaking... > > Enjoy... *Jim H. > > Code starts here: > > on error resume next > Set objOutlook = CreateObject("Outlook.Application.11") ' Opens > Outlook object > Set objNS = objOutlook.GetNamespace("MAPI") ' Specifies MAPI namespace > in the Outlook object > Set objFSO = CreateObject("Scripting.FileSystemObject") ' used to get > file system data for PST files > Set WshNetwork = WScript.CreateObject("WScript.Network") ' Used to get > logged on user name > user = ucase(WshNetwork.UserName) > > For Each objFolder In objNS.Folders > > if GetPSTPath(objFolder.StoreID) <> "" then ' You should only return > items with a StoreID value > > * * * * *pstfiles = GetPSTPath(objFolder.StoreID) > > * * * * * * * * *Set objFile = objFSO.GetFile(pstfiles) > > filename = "The folder named: " & vbtab & *vbtab & objFolder.name & > vbcrlf & _ > "is in this file:" & vbtab & GetPSTPath(objFolder.StoreID) & _ > *vbcrlf & vbcrlf & "Date created: " & objFile.DateCreated & vbcrlf & _ > *"Date last accessed: " & objFile.DateLastAccessed & vbcrlf & _ > *"Date last modified: " & objFile.DateLastModified & vbcrlf & _ > *"File Size: " & objFile.Size / 1024 & " KB" & vbcrlf & vbcrlf & _ > > "--------------------------------------------------------------------------*----------" > > ' The next line allows for the filelist variable to get multiple > iterations of the PST value(s) before displaying the MSGBOX > > filelist = filelist & filename & VbCrLf & VBCRLF > > end if > > Next > > if filelist = "" then > filelist = " * * * NO PERSONAL FOLDERS FILES FOUND IN THE CURRENT > PROFILE *" > end if > > msgbox "Logged on user is: " & user & vbcrlf & vbcrlf & _ > "The PST files listed in your Outlook profile are at the locations > shown below: " & _ > vbcrlf & vbcrlf & > "--------------------------------------------------------------------------*----------" > & _ > * vbcrlf & vbcrlf & filelist > > Function GetPSTPath(input) > > * *For i = 1 To Len(input) Step 2 > * * * *strSubString = Mid(input,i,2) > * * * *If Not strSubString = "00" Then > * * * * * *strPath = strPath & ChrW("&H" & strSubString) > * * * *End If > * *Next > > * *Select Case True > * * * *Case InStr(strPath,":\") > 0 > * * * * * *GetPSTPath = Mid(strPath,InStr(strPath,":\")-1) > * * * *Case InStr(strPath,"\\") > 0 > * * * * * *GetPSTPath = Mid(strPath,InStr(strPath,"\\")) > * *End Select > End Function formatted in a text editor. Jim |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Conditional execution of script for logged-on user | VB Script | |||
| Script to find all user and what PC they are logged into | VB Script | |||
| Script to delay launch of program(s) | VB Script | |||
| Listing Directories in file Search | PowerShell | |||
| Listing file versions | PowerShell | |||