Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executing exe in vb.net 1

Status
Not open for further replies.

josie2007

Technical User
Apr 14, 2007
90
US
The program just does not execute...but when I go run the exe manually it works fine. any clue?
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
System.Diagnostics.Process.Start("C:\Expedite\Gen.exe")

End Sub
 
The short answer is no. You would need to create them seperate... but you could reuse "p" by starting the first one, setting p = new process for the second one.

Should do something like this though...
p.StartInfo.FileName = "C:\Expedite\eblib.exe"
p.StartInfo.Arguments= "/a Josie *.ebs"


Senior Software Developer
 
SiriusBlackOp thank you for the response.The ebs files which are supposed to be generated by the firs exe files are not generated.here is what my code looks like using your suggestion


Else
Dim p As New Process
p.StartInfo.FileName = "C:\Expedite\Gen.exe"
p = New Process
p.StartInfo.FileName = "C:\Expedite\eblib.exe"
p.StartInfo.Arguments = "/a Josie *.ebs"
p.StartInfo.WorkingDirectory = "C:\Expedite\"
p.Start()

TextBox1.Text = "EBS Files Has Been Generated.It Is On C:\Expedite Folder " & vbNewLine
TextBox1.Text += "Now You Can Transfer these EBS files to Bidx."
GetEbsFiles.Enabled = True
End If
 
That won't work. Before reallocating p you need to use it i.e. p.Start must come before you use p.StartInfo.Filename etc. for a second time.


Hope this helps.


[vampire][bat]
 
Also, if you intend to re-use p, you don't need p = New Process a second time.

[vampire][bat]
 
Change to:
Dim p As New Process
p.StartInfo.FileName = "C:\Expedite\Gen.exe"
p.StartInfo.WorkingDirectory = "C:\Expedite\"
p.Start()
p = New Process
p.StartInfo.FileName = "C:\Expedite\eblib.exe"
p.StartInfo.Arguments = "/a Josie *.ebs"
p.StartInfo.WorkingDirectory = "C:\Expedite\"
p.Start()

TextBox1.Text = "EBS Files Has Been Generated.It Is On C:\Expedite Folder " & vbNewLine
TextBox1.Text += "Now You Can Transfer these EBS files to Bidx."
GetEbsFiles.Enabled = True


Senior Software Developer
 
earthandfire... Personally I would because it is still referencing the process it just stared.

Maybe it would work your way just fine, but I wouldn't risk it.

Senior Software Developer
 
I did it this way and seems to work fine. but do not know this is the right way. Please if you have any comments or suggestions let me know as it will help me learing more about vb.net. thanks all

Dim p As New Process
p.StartInfo.FileName = "C:\Expedite\Gen.exe"
p.StartInfo.WorkingDirectory = "C:\Expedite\"
p.Start()
p.StartInfo.FileName = "C:\Expedite\eblib.exe"
p.StartInfo.Arguments = "/a Josie *.ebs"
p.StartInfo.WorkingDirectory = "C:\Expedite\"
p.Start()
 
I didn't post an example because I felt just a minor change was needed, but ...

try this:

Code:
    Dim p As New Process
    Dim psi As New ProcessStartInfo

    psi.FileName = "Notepad.exe"
    p.StartInfo = psi

    p.Start()
    p.WaitForExit()

    psi.FileName = "Excel.exe"
    p.Start()
    p.WaitForExit()


Hope this helps


[vampire][bat]
 
I would think about something like this to be honest.

------------------------------------
'Dimention Processes
Dim p1 As New Process
Dim p2 As New Process
'Set File Names
p1.StartInfo.FileName = "C:\Expedite\Gen.exe"
p2.StartInfo.FileName = "C:\Expedite\eblib.exe"
'Set Working Directories
p1.StartInfo.WorkingDirectory = "C:\Expedite\"
p2.StartInfo.WorkingDirectory = "C:\Expedite\"
'Set Args
p2.StartInfo.Arguments = "/a Josie *.ebs"
' -- Assuming that p1 should finish prior to p2 starting.
'Start p1
p1.Start()
'Wait up to 30 sec for p1 to exit
Dim iSec As Int16 = 30
Do Until p1.HasExited
'sleep for 1 second
System.Threading.Thread.Sleep(1000)
iSec -= 1
If iSec = 0 Then
Throw New System.Exception("First Process Failed to stop processing in a timely fasion.")
Exit Do
End If
Loop
'May want to decide if p2 should run if p1 hasn't finished.
p2.Start()

Senior Software Developer
 
perfect...thanks for the valuable info. you shared it with me. thank you all for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top