VBSCRIPT : Automating Offline Defrag in Exchange 2000 
Author Message
 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?



Sat, 26 Nov 2005 03:38:21 GMT  
 VBSCRIPT : Automating Offline Defrag in Exchange 2000
Quote:

> 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.

    ---snip---

Quote:
> 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.

You have to run the command shell to get redirection...

pathtorun = "%comspec% /c " & sRunDefrag &" >>c:\"&oMailstore&"Status.txt"

--
Michael Harris
Microsoft.MVP.Scripting



Sat, 26 Nov 2005 05:25:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. scripts for Automating Exchange 2000 installation

2. scripts for Automating Exchange 2000 installation

3. Windows 2000 defrag without sendkeys

4. Creating Exchange Mailbox with Win2000 & Exchange 2000

5. Content filter for Exchange 2000/SMTP 2000

6. Exchange 2000 recipient force in VBScript??

7. setting offline folder access in exchange with vbscript

8. ********* How to run defrag from command prompt on Windows 2000

9. ********* How to run defrag from VB on Windows 2000

10. Outlook 2000 exchange 2000 workflow

11. Global Journal in Outlook 2000/Exchange 2000

12. Automating email function within Word 2000 using Access 2000

 

 
Powered by phpBB® Forum Software