Launch batch file and pass control back to VBScript


H

Highlander

(watch for word wrap below)

Hello all.

Here's a section of VBScript code I've got on a Windows 2003 server:

==================================================
strAppServer = "WAS_AppServer5"
strCMD = "%COMSPEC% /c LaunchAppServer.bat " & strAppServer
Set objCMD = objShell.Exec(strCMD)
sPIDText = "open for e-business; process id is"
StartTime = Timer( )
Do
'~~ Get the output of strCMD
IF Not objCMD.StdOut.AtEndOfStream Then
strLine = objCMD.StdOut.ReadLine
WScript.Echo strLine
End IF
'~~ If process id text is present, exit loop
IF inStr(1, strLine, sPIDText, 1) Then
Exit Do
End IF
'~~ If timeout is reached, exit loop
IF Timer( ) > StartTime + 300 Then
WScript.Echo vbCrlf & "*** TIMED OUT ***"
Exit Do
End IF
WScript.Sleep 100
Loop
EndTime = Timer( )
sElapsed = "Elapsed seconds: " & (EndTime - StartTime)
WScript.Echo vbCrlf & sElapsed & vbCrlf
==================================================


This VBScript, configured to run when the server reboots, is designed
to start the WebSphere Application Servers on the machine. (there are
6). This script essentially launches the batch file
"LaunchAppServer.bat":

=================================================
@ECHO OFF
D:\IBM\WebSphere\AppServer6\profiles\AppSrv01\bin\startserver %1
=================================================

In the section of VBScript code above, I'm capturing the output of
objShell.Exec(strCMD). When an Application Server starts up
successfully, the correct output looks like this:

========================================================
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: WAS_AppServer1
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server WAS_AppServer1 open for e-business; process id is
364
========================================================


The problem is that one of the 6 WebSphere Application Servers on the
machine doesn't start up. The last line of the output is:

"ADMU3200I: Server launched. Waiting for initialization status."

And then it just waits forever.

I've put a timer in the VBScript code, so that after 5 minutes it will
cease waiting, and continue processing the VBScript. That doesn't work
however, because it appears that control is still in the "startserver"
process; control is never passed back to the VBScript. The very last
thing the VBScript does is output the line "...Waiting for
initialization status." And that's it.

How can I configure the VBScript or the batch file it launches to
insure that control is passed back to the VBScript?

Any help would be greatly appreciated. Thanks!

- Dave
 
Ad

Advertisements

P

Pegasus \(MVP\)

Highlander said:
(watch for word wrap below)

Hello all.

Here's a section of VBScript code I've got on a Windows 2003 server:

==================================================
strAppServer = "WAS_AppServer5"
strCMD = "%COMSPEC% /c LaunchAppServer.bat " & strAppServer
Set objCMD = objShell.Exec(strCMD)
sPIDText = "open for e-business; process id is"
StartTime = Timer( )
Do
'~~ Get the output of strCMD
IF Not objCMD.StdOut.AtEndOfStream Then
strLine = objCMD.StdOut.ReadLine
WScript.Echo strLine
End IF
'~~ If process id text is present, exit loop
IF inStr(1, strLine, sPIDText, 1) Then
Exit Do
End IF
'~~ If timeout is reached, exit loop
IF Timer( ) > StartTime + 300 Then
WScript.Echo vbCrlf & "*** TIMED OUT ***"
Exit Do
End IF
WScript.Sleep 100
Loop
EndTime = Timer( )
sElapsed = "Elapsed seconds: " & (EndTime - StartTime)
WScript.Echo vbCrlf & sElapsed & vbCrlf
==================================================


This VBScript, configured to run when the server reboots, is designed
to start the WebSphere Application Servers on the machine. (there are
6). This script essentially launches the batch file
"LaunchAppServer.bat":

=================================================
@ECHO OFF
D:\IBM\WebSphere\AppServer6\profiles\AppSrv01\bin\startserver %1
=================================================

In the section of VBScript code above, I'm capturing the output of
objShell.Exec(strCMD). When an Application Server starts up
successfully, the correct output looks like this:

========================================================
ADMU0128I: Starting tool with the AppSrv01 profile
ADMU3100I: Reading configuration for server: WAS_AppServer1
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server WAS_AppServer1 open for e-business; process id is
364
========================================================


The problem is that one of the 6 WebSphere Application Servers on the
machine doesn't start up. The last line of the output is:

"ADMU3200I: Server launched. Waiting for initialization status."

And then it just waits forever.

I've put a timer in the VBScript code, so that after 5 minutes it will
cease waiting, and continue processing the VBScript. That doesn't work
however, because it appears that control is still in the "startserver"
process; control is never passed back to the VBScript. The very last
thing the VBScript does is output the line "...Waiting for
initialization status." And that's it.

How can I configure the VBScript or the batch file it launches to
insure that control is passed back to the VBScript?

Any help would be greatly appreciated. Thanks!

- Dave
See the reply/replies to your identical post in "scripting.vbscript".
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Batch file to delete files by date (Or VBScript?) 4
batch file 5
batch file 3
batch file 4
Batch files 1
Batch file 3
batch file problem 8
logging batch files 8

Top