NewBie

  • Thread starter Thread starter Miro
  • Start date Start date
M

Miro

Are you sure that "wait 1000" needs to be there?

I pulled this example off the net.
====
Private Sub btnWaitForExit_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnWaitForExit.Click

' create a new process
Dim myProcess As Process = _
System.Diagnostics.Process.Start("sample.txt")

' wait until it exits
myProcess.WaitForExit()

' display results
MessageBox.Show("Notepad was closed at: " & _
myProcess.ExitTime & "." & _
System.Environment.NewLine & "Exit Code: " & _
myProcess.ExitCode)
myProcess.Close()
End Sub


======


Miro
 
Hello all,

I am very new to vb.net and am looking for help to resolve an issue I am
having.

What I am trying to do: Install IIS by executing sysocmgr.exe

Issue: I need to wait until the execution of sysocmgr.exe is complete
before moving forward w/ the rest of my code
However, when I try to use the provided "waitforexit()" function, I get an
error, furthermore, ANYTHING i execute after the ".start()", that isnt
writing to a log file, makes the ".start()" fail. If I remove the
".waitforexit()" the process works correctly. SYSOCMGR.exe executes w/
passed parameters and IIS gets intstalled.

Error: Windows Setup - The application could not be initialize


PLEASE HELP. this is driving me nuts. ~TYAVMIA~

Here is my code:

Dim objProcess As System.Diagnostics.Process
Dim wait As Integer
wait = 10000
Try
objProcess = New System.Diagnostics.Process
objProcess.StartInfo.FileName = "sysocmgr.exe"
objProcess.StartInfo.Arguments = " /i:sysoc.inf
/u:C:\TEMP\IISConfigFile.txt"
objProcess.Start()

'Wait until the process passes back an exit code
objLogFile.WriteLine("I now have to figure out how to make ths
sleep!!!")
objProcess.WaitForExit(wait)

'Free resources associated with this process
objProcess.Close()
Catch
objLogFile.WriteLine("Could not start process " & ProcessPath,
"Error")
End Try
 
Miro,

Thanks for your response. Per MSDN documentation, you can either pass
the WaitForExit () function a parameter (int32) "Instructs the Process
component to wait the specified number of milliseconds for the associated
process to exit. " or leave it empty "Instructs the Process component to
wait indefinitely for the associated process to exit. ". I've tried passing
it a parameter (as you can see in my original code) and leaving it empty,
either way it executes with the same error.

http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.waitforexit.aspx
 
Back
Top