By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,418 Members | 1,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,418 IT Pros & Developers. It's quick & easy.

WaitForExit: No process is associated with this object.

P: n/a
Using the following code, I get the error "No process is associated with
this object" when calling the WinZip.WaitForExit() method. After I
click the "Break" or "Continue" button on the dialog, the app exits but
then the command window opens and the process runs on its own. Could
the "WaitForExit" call be happening too soon?

Private Sub ZipDirs(ByVal PCName As String)
Dim WinZip As New System.Diagnostics.Process
Dim args As String = " -Pru -ex " & lblFolder.Text & "\" & PCName &
".zip @""" & appPth & "WksBkup.txt"""
Dim SI As New ProcessStartInfo("c:\Program Files\WinZip\wzzip.exe",
args)
'WinZip.EnableRaisingEvents = True
WinZip.Start(SI)
WinZip.WaitForExit()
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
I finally got it to work, see the code below. I don't understand why
some ways work and others dont.
Private Sub ZipDirs(ByVal PCName As String)
Dim WinZip As New System.Diagnostics.Process
Dim args As String = " -Pru -ex " & lblFolder.Text & "\" & PCName &
".zip @""" & appPth & "WksBkup.txt"""
Dim SI As New ProcessStartInfo("c:\Program Files\WinZip\wzzip.exe",
args)

'THIS WORKS (WaitForExit waits)
WinZip.StartInfo = SI
WinZip.Start()

'THIS DOESN'T WORK (WaitForExit throws)
WinZip.Start(SI)

WinZip.WaitForExit()
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #2

P: n/a
Hello Terry,

Your mistake is that "Start(ByVal ProcessStartInfo) as Process" is Shared
method of Process class and is returning a new Process object.

For now you are:
1. Creating new process without any startup info (Dim WinZip as New ...);
2. Starting a NEW process with SI startupinfo object (WinZip.Start(SI));
created process object goes into nothing;
3. Calling WaitForExit method of WinZip object which is actually empty
(WinZip.WaitForExit()), obviously causing an exception.

So, you need to remake your code:

~
Dim args as String = "...", SI As New ProcessStartInfo(...)
Dim WinZip As Process = Process.Start(SI) REM (!)
WinZip.Start()
WinZip.WaitForExit()
~

Or:

~
Dim args, SI...
Dim WinZip As New Process()
WinZip.StartInfo = SI
WinZip.Start()
WinZip.WaitForExit()
~

I hope this helps.

Dragon

"Terry Olsen" <to******@hotmail.com> ???????/???????? ? ???????? ?????????:
news:#2**************@TK2MSFTNGP12.phx.gbl...
Using the following code, I get the error "No process is associated with
this object" when calling the WinZip.WaitForExit() method. After I
click the "Break" or "Continue" button on the dialog, the app exits but
then the command window opens and the process runs on its own. Could
the "WaitForExit" call be happening too soon?

Private Sub ZipDirs(ByVal PCName As String)
Dim WinZip As New System.Diagnostics.Process
Dim args As String = " -Pru -ex " & lblFolder.Text & "\" & PCName &
".zip @""" & appPth & "WksBkup.txt"""
Dim SI As New ProcessStartInfo("c:\Program Files\WinZip\wzzip.exe",
args)
'WinZip.EnableRaisingEvents = True
WinZip.Start(SI)
WinZip.WaitForExit()
End Sub

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.