1

I have a console application that is built in VB.Net. Now I have a timer in that application. All I want to do is at a particyualr time i will call another exe (which is built in VB 6.0) and again get the control back to this console application. Now what is happening is that I am being able to call the second exe from the console application , but then the control is not returning back to the same console application. Any help will be much appreciated. Thank you in advance

Rajdeep
  • 485
  • 4
  • 15
  • 28

1 Answers1

0
Process.Start(myProgramPathAndFileName)

This should create a new process and return control to your console app.

You can do more with this process by storing the return value:

MyProcess = Process.Start(myProgramPathAndFilename)

Then call this when your application exits

MyProcess.Kill

See: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx for more info on processes.

See: .NET Console Application Exit Event for information on handling Application Exit as an event.

Community
  • 1
  • 1
Ken Gregory
  • 7,180
  • 1
  • 39
  • 43
  • @@Ken:: Your post seems to work ok, but when the console application is closed , can we close the other EXE without changing any code in the other EXE.?? – Rajdeep May 05 '11 at 09:36
  • Yes. Grab the process id. Kill it on application exit. – Ken Gregory May 05 '11 at 11:00
  • I have the process ID , I know how to kill it. But I am confused where to write this code. I have implemented a logic by which my console app will not close untill and unless i write 'EXIT'. the code is given below: – Rajdeep May 05 '11 at 11:30
  • While console.readline.trim.toupper<>"EXIT") console.writeline ("") end while – Rajdeep May 05 '11 at 11:32
  • I think that might be another question in itsself - fortunately there's a lot of resources on this site. Someone else wanted to trap the application exit of a console app in this question: http://stackoverflow.com/questions/1119841/net-console-application-exit-event You should do something similar and kill the process within that event. – Ken Gregory May 05 '11 at 11:38