I copied the script from msdn

Option Explicit

Dim sFileName, sFilePath

sFileName = "*.pst"
sFilePath = "U:\"

Dim oFS 'file system object

Set oFS = WScript.CreateObject("Scripting.FileSystemObject")

FindFile sFilePath, oFS

Sub FindFile(path, fso)

Dim oFC 'file collection object
Dim oFolder 'folder object
Dim eFile 'file element
Dim eFolder 'folder element

Set oFC = fso.GetFolder(path)

For Each eFile In oFC.Files'
If eFile.Name = sFileName Then
'echo file path
WScript.Echo eFile.Path
End If
Next

Set oFolder = oFC.SubFolders

'recursion starts here
For Each eFolder In oFolder
FindFile eFolder.Path, fso
Next
End Sub

I would like to first search in the c:\ than in the u:\. When I did the
search I got an error Access denied and The script stopped. I would like to
skip the file and keep going.

Re: Find pst files on c:\ and u:\ by Pegasus

Pegasus
Fri May 02 14:40:14 CDT 2008


"freddy" <freddy@discussions.microsoft.com> wrote in message
news:564FA459-5A1D-45B2-91D6-24EC62389636@microsoft.com...
>I copied the script from msdn
>
> Option Explicit
>
> Dim sFileName, sFilePath
>
> sFileName = "*.pst"
> sFilePath = "U:\"
>
> Dim oFS 'file system object
>
> Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
>
> FindFile sFilePath, oFS
>
> Sub FindFile(path, fso)
>
> Dim oFC 'file collection object
> Dim oFolder 'folder object
> Dim eFile 'file element
> Dim eFolder 'folder element
>
> Set oFC = fso.GetFolder(path)
>
> For Each eFile In oFC.Files'
> If eFile.Name = sFileName Then
> 'echo file path
> WScript.Echo eFile.Path
> End If
> Next
>
> Set oFolder = oFC.SubFolders
>
> 'recursion starts here
> For Each eFolder In oFolder
> FindFile eFolder.Path, fso
> Next
> End Sub
>
> I would like to first search in the c:\ than in the u:\. When I did the
> search I got an error Access denied and The script stopped. I would like
> to
> skip the file and keep going.

This is a standard maintenance task that can be performed with a
standard command line tool:

dir /s /b u:\*.pst