Help with PST copy

Author Message
timassin

  • Total Posts : 14
  • Scores: 0
  • Reward points : 0
  • Joined: 11/14/2011
  • Status: offline
Help with PST copy Thursday, February 02, 2012 1:39 AM (permalink)
0
[Helpful answer received] / [List Solutions Only]
Hello All,
I'm trying to create a script that will search the local machine for all .pst and .ost files then copy them into another folder. Once they are copied over to another folder I can use a robocopy script to copy all the files from that folder to our server. I'd also like to add an echo in the vbscript that tells the user to close Lync and outlook before continuing. I have this so far,
 
 strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile Where Extension = 'pst'") For Each objFile in colFiles 

 
Thanks for the help in advance,
Tim
 
#1
    59cobalt

    • Total Posts : 972
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: online
    Re:Help with PST copy Thursday, February 02, 2012 7:49 AM (permalink)
    0
    Use FileSystemObject instead of WMI and spare yourself a lot of hassle.
     
    #2
      timassin

      • Total Posts : 14
      • Scores: 0
      • Reward points : 0
      • Joined: 11/14/2011
      • Status: offline
      Re:Help with PST copy Friday, February 03, 2012 4:42 AM (permalink)
      0
      The only thing with Filesystemobject I can't figure out a way to search for files by extension through the whole c drive.
       
      #3
        ebgreen

        • Total Posts : 8227
        • Scores: 98
        • Reward points : 0
        • Joined: 7/12/2005
        • Status: offline
        Re:Help with PST copy Friday, February 03, 2012 4:52 AM (permalink)
        4
        Search this forum for:
         
        Recursive search
        Recursion
        "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
        Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
        http://www.visualbasicscript.com/m_47117/tm.htm
         
        #4
          59cobalt

          • Total Posts : 972
          • Scores: 91
          • Reward points : 0
          • Joined: 7/17/2011
          • Status: online
          Re:Help with PST copy Saturday, February 04, 2012 10:38 AM (permalink)
          4
          It's an FAQ, too.
           
          #5
            timassin

            • Total Posts : 14
            • Scores: 0
            • Reward points : 0
            • Joined: 11/14/2011
            • Status: offline
            Re:Help with PST copy Monday, February 06, 2012 7:20 AM (permalink)
            0
            [This post was marked as helpful]
            Thanks for your help guys, heres my final script seems to be working pretty well.
             
             Option Explicit 'Messagebox asking to close outlook 
             MsgBox "Please close Outlook and Lync before pressing ok." Const DestFolder = "C:\scripts2\archive\" CopyFiles Sub CopyFiles 
               ' folder to look in 
               Dim strFolderPath : strFolderPath = "C:\" 
               
               Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject") 
               Dim RegEx : Set RegEx = New RegExp 
               ' specify the extension you want to search for; seperate with a | 
               ' currently searching for .pdf and .rpt files 
               RegEx.Pattern = "\.(pst|ost)$" 
               RegEx.IgnoreCase = True 
                  RecurseFolder objFSO, strFolderPath, RegEx 
            End Sub 
            Sub RecurseFolder(objFSO, strFolderPath, RegEx) 
               Dim objFolder : Set objFolder = objFSO.GetFolder(strFolderPath) 
               
               Dim objFile, strFileName 
               For Each objFile In objFolder.Files 
                   strFileName = objFile.Path 
                   If RegEx.Test(strFileName) Then objFile.Copy DestFolder 
               Next On Error Resume Next
               
               Dim objSubFolder 
               For Each objSubFolder In objFolder.SubFolders 
                   RecurseFolder objFSO, objSubFolder.Path, RegEx 
               Next On Error GoTo 0 
            End Sub 'Shell script to run the ROBOCOPY script
             dim shell
            set shell=createobject("wscript.shell")
             shell.run "C:\scripts\robocopyscript.cmd"
             set shell=nothing 'Messagebox syaing completed 
             MsgBox "The Copy is complete" 

             
            Thanks,
            Tim
             
            #6

              Online Bookmarks Sharing: Share/Bookmark

              Jump to:

              Current active users

              There are 0 members and 1 guests.

              Icon Legend and Permission

              • New Messages
              • No New Messages
              • Hot Topic w/ New Messages
              • Hot Topic w/o New Messages
              • Locked w/ New Messages
              • Locked w/o New Messages
              • Read Message
              • Post New Thread
              • Reply to message
              • Post New Poll
              • Submit Vote
              • Post reward post
              • Delete my own posts
              • Delete my own threads
              • Rate post

              2000-2012 ASPPlayground.NET Forum Version 3.9