![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Launch batch file and pass control back to VBScript (sorry about the duplicate post - forgot to include this group) (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 |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Launch batch file and pass control back to VBScript "Highlander" <tron9901@xxxxxx> wrote in message news:c96d8bce-4549-41b1-96bc-c60ef262acb1@xxxxxx Quote: > (sorry about the duplicate post - forgot to include this group) > > (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 @ECHO OFF D:\IBM\WebSphere\AppServer6\profiles\AppSrv01\bin\startserver %1 what is "startserver"? Is it an .exe file? A .bat file? How do you know that "startserver" finishes? Have you tried monitoring it, e.g. like so: @ECHO OFF echo %date% %time% Startserver started 1>> c:\test.txt 2>>&1 D:\IBM\WebSphere\AppServer6\profiles\AppSrv01\bin\startserver %1 echo %date% %time% Startserver ended 1>> c:\test.txt 2>>&1 |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| vbscript and batch files | VB Script | |||
| How can I pass a datatable to a web user control | .NET General | |||
| How to pass values from script to external batch files | PowerShell | |||
| Tried to revert back to XP, now my MSI 1029 notebook won't pass BI | Vista General | |||
| Tried to revert back to XP, now my MSI 1029 notebook won't pass BI | Vista General | |||