Thanks Mattias. I have done some experimenting with this, and can pass in
the args I need for the scripts. The problem I have with this method is
getting an indication of success or failure of the transmission. I can
access the exitcode for pw5.exe by listening for .HasExited, but that exit
code only indicates whether the program terminated abnormally or not and does
not give me any indication of the success or failure of my transmission.
JT
"Mattias Sjögren" wrote:
> Thanks Mattias. I have done some experimenting with this, and can pass in
> the args I need for the scripts. The problem I have with this method is
[quoted text clipped - 3 lines]
> does
> not give me any indication of the success or failure of my transmission.
Check the docs for HasExited and you will find this:
<quote>
If a handle is open to the process, the operating system releases the
process memory when the process has exited, but retains administrative
information about the process, such as the handle, exit code, and exit time.
To get this information, you can use the ExitCode and ExitTime properties.
These properties are populated automatically for processes that were started
by this component. The administrative information is released when all the
Process components that are associated with the system process are destroyed
and hold no more handles to the exited process.
</quote>
Regards,
Will
JTnospam@verizon.net - 18 Oct 2004 20:01 GMT
Thanks William,
I have read the documentation, but I am not sure what to do with it to get
the return value I seek. My code is as follows;
Private Function TransmitFiles(ByVal strScriptArgs As String) As Integer
Try
If strScriptArgs.Length > 0 Then
Dim myProcomm As New Process
With myProcomm.StartInfo
.FileName = "pw5.exe"
.Arguments = strScriptArgs
.WindowStyle = ProcessWindowStyle.Hidden
End With
With myProcomm
If .Start() Then
If .HasExited Then
Return .ExitCode
End If
Else
Return 1 'Failed to start
End If
End With
End If
Catch ex As System.ComponentModel.Win32Exception
If ex.NativeErrorCode = 2 Then 'File Not Found Error
Return 2
ElseIf ex.NativeErrorCode = 5 Then 'Access Denied Error
Return 5
End If
End Try
End Function
JT
> > Thanks Mattias. I have done some experimenting with this, and can pass in
> > the args I need for the scripts. The problem I have with this method is
[quoted text clipped - 19 lines]
> Regards,
> Will
William DePalo [MVP VC++] - 18 Oct 2004 20:04 GMT
> Thanks William,
You are welcome.
> I have read the documentation, but I am not sure what to do with it to get
> the return value I seek. My code is as follows;
If the process you start returns a return code then ExitCode should pick it
up. Many processes simply return 0.
Regards,
Will