
VBSCRIPT : Automating Offline Defrag in Exchange 2000
Currently I have a script that allows for offline defrag of Exchange
Mailstores. I have run into an issue of running the eseutil.exe from the
command prompt and capturing to the txt file.
//////////////////////////////////////////
sRunDefrag = "E:\exchsrvr\BIN\eseutil.exe /d "&oDirectory&" /b
E:"&oMailstore&"bak /t E:"&oMailstore&"tmp"
cdir = "E:\" 'Drive your defrag executable is on
pathtorun = sRunDefrag &" >>c:\"&oMailstore&"Status.txt" ' this would be
"defrag servername >> logfile"
logfiletomonitor = "E:\OfflineDefrag\"&oMailstore&"bak"
howoftentocheck = 900 'Check the file x many seconds (approx) 30 minutes
would be 1800
set process = getobject("winmgmts:!Win32_Process")
WScript.Echo pathtorun
rc = process.create(pathtorun,cdir,,pid)
Set wmiLocator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set svc = wmiLocator.Connectserver(WSHnetwork.computername)
Set FSO=CreateObject("Scripting.FileSystemObject")
isrunning = True
filesize = 0
loopcounter = 0
gothung = false
Do While isrunning = True
isrunning = False
loopcounter = loopcounter + 1
Set objs = svc.InstancesOf("Win32_Process")
for each obj in objs
if obj.ProcessId = pid Then isrunning = True
Next
If loopcounter = howoftentocheck Then
loopcounter = 0
If FSO.GetFile(logfiletomonitor).Size > filesize Then
filesize = FSO.GetFile(logfiletomonitor).Size
else
gothung = True
Exit do
End if
End if
WScript.Sleep(500)
Loop
Set objs = svc.InstancesOf("Win32_Process")
for each obj in objs
if obj.ProcessId = pid Then obj.Terminate
Next
If gothung = False Then
FindStatus
Else
DefragLocked
End If
End Sub
////////////////////////////////////////////
The issue is when run via the script it only runs the "E:\exchsrvr\BIN
\eseutil.exe" part and disreguards the rest of the command line parameters.
Any thoughts on how to get it to play nicely?