I am using the VB6 Setup Toolkit to write an install procedure to install MSDE and attach a database. I've got the MSDE launching, but then it hangs and after I've waited long enough to be convinced it's really stuck (I know MSDEx86 takes a good long while to install), the Task Manager shows that the Setup.exe process is taking 99% of the CPU and the msdex86.exe process has only had 5 seconds of run time.
Here's the code I figure it's sticking on.
sqlcmd = Chr(34) & gstrDestDir & "setup\msdex86.exe" & Chr(34) & "-a -SMS -s -f1 " & Chr(34) & gstrDestDir & "setup\setup.iss" & Chr(34)
ExecCmd sqlCmd
Public Sub ExecCMD(cmdLine)
' Start the shelled application:
ret = CreateProcessA(0&, cmdline, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, Start, Proc)
' Wait for the shelled application to finish. Note that the setup does some
' posting of messages to the desktop. If we simply waited for the setup to finish
' via WaitForSingleObject, the VB application would not be processing these messages
' and the setup would hang. So we use MsgWaitForMultipleObjects and the DoEvents()
' function to allow the VB app to process these messages and allow setup to finish.
i = 0
Do
ret = MsgWaitForMultipleObjects(1&, Proc.hProcess, 0&, INFINITE, _
(QS_POSTMESSAGE Or QS_SENDMESSAGE))
If ret = (WAIT_OBJECT_0) Then Exit Do 'The process ended.
OpenForms = DoEvents()
' Cut off the process if it does not respond.
' The higher the number, the more tolerant the installation.
If i = 99999 Then
CloseHandle (Proc.hProcess)
Call MsgBox("There is no response from the command line statement. Process Terminated", vbCritical)
Err.Raise (0)
End If
i = i + 1
Loop
Thank you.
Here's the code I figure it's sticking on.
sqlcmd = Chr(34) & gstrDestDir & "setup\msdex86.exe" & Chr(34) & "-a -SMS -s -f1 " & Chr(34) & gstrDestDir & "setup\setup.iss" & Chr(34)
ExecCmd sqlCmd
Public Sub ExecCMD(cmdLine)
' Start the shelled application:
ret = CreateProcessA(0&, cmdline, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, Start, Proc)
' Wait for the shelled application to finish. Note that the setup does some
' posting of messages to the desktop. If we simply waited for the setup to finish
' via WaitForSingleObject, the VB application would not be processing these messages
' and the setup would hang. So we use MsgWaitForMultipleObjects and the DoEvents()
' function to allow the VB app to process these messages and allow setup to finish.
i = 0
Do
ret = MsgWaitForMultipleObjects(1&, Proc.hProcess, 0&, INFINITE, _
(QS_POSTMESSAGE Or QS_SENDMESSAGE))
If ret = (WAIT_OBJECT_0) Then Exit Do 'The process ended.
OpenForms = DoEvents()
' Cut off the process if it does not respond.
' The higher the number, the more tolerant the installation.
If i = 99999 Then
CloseHandle (Proc.hProcess)
Call MsgBox("There is no response from the command line statement. Process Terminated", vbCritical)
Err.Raise (0)
End If
i = i + 1
Loop
Thank you.