Want to execuete external applictaion in VB.NET application
hi,
The progarm i am executing should execute first and then the main program its like adding pre-run program.Like in modal appliction and messageboxes.
Please help me soon.....
Try to mail me ataramjyotsingh@gmail.com" href="mailto_3Cimg src="/library/msdn/emoticons/emotion-4.gif" alt="Stick out tongue" />aramjyotsingh@gmail.com">paramjyotsingh@gmail.com
Thanking you!
To run an application from you VB programm, look at the PROCESS class. Here is a collection of overloads that use it.
#Region "RunProcess"
Private Overloads Function RunProcess(ByVal pString As String) As Boolean
Return RunProcess(True, pString, 2147483647, "") 'pass no arguments and max int32 value for infinite wait time
End Function
Private Overloads Function RunProcess(ByVal pString As String, ByVal WaitTime As Int32) As Boolean
Return RunProcess(True, pString, WaitTime, "") 'pass no arguments and max int32 value for infinite wait time
End Function
Private Overloads Function RunProcess(ByVal DoNotCreateWindow As Boolean, ByVal pString As String) As Boolean
Return RunProcess(DoNotCreateWindow, pString, 2147483647, "") 'pass no arguments and max int32 value for infinite wait time
End Function
Private Overloads Function RunProcess(ByVal DoNotCreateWindow As Boolean, ByVal pString As String, ByVal WaitTime As Int32) As Boolean
Return RunProcess(DoNotCreateWindow, pString, WaitTime, "") 'pass a max int32 value for infinite wait time
End Function
Private Overloads Function RunProcess(ByVal DoNotCreateWindow As Boolean, ByVal pString As String, ByVal args As String) As Boolean
Return RunProcess(DoNotCreateWindow, pString, 2147483647, args) 'pass a max int32 value for infinite wait time
End Function
Private Overloads Function RunProcess(ByVal DoNotCreateWindow As Boolean, ByVal pString As String, ByVal WaitTime As Int32, ByVal args As String) As Boolean
Dim p As New Process
Dim ExitState As Boolean = False
p.StartInfo.FileName = pString
p.StartInfo.Arguments = args
p.StartInfo.CreateNoWindow = DoNotCreateWindow
Try
p.Start()
If WaitTime <> 0 Then
ExitState = p.WaitForExit(WaitTime) 'exit state will be true if the process is terminated before WaitTime
If Not p.HasExited Then
p.Kill() 'else it will return false
End If
End If
Catch ex As System.ComponentModel.Win32Exception
MessageBox.Show(pString & ControlChars.CrLf & "Could not start because the file could not be found")
End Try
Return ExitState
End Function
#End Region
HTH
kevin