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)
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
|
|
|
|
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)
|
|
|
|
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)
The only thing with Filesystemobject I can't figure out a way to search for files by extension through the whole c drive.
|
|
|
|
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)
Search this forum for: Recursive search Recursion
|
|
|
|
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)
|
|
|
|
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)
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
|
|
|
|