5 Replies - 16146 Views - Last Post: 08 February 2011 - 05:33 AM Rate Topic: -----

#1 warhawk  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 42
  • Joined: 22-March 09

Opening/closing external programs

Posted 15 June 2009 - 03:42 PM

Hi everyone!

I want to make a program where I can open a program, and my vb program starts with it. My VB program will then use a timer to count to an hour, and then close out of both programs. So i started experementing with things and this is what i came up with:
Dim myprocess As Process = System.Diagnostics.Process.Start("C:\Program Files\Internet Explorer\iexplore.exe")


That opens my program fine, but I dont know how to close it from there. Also I want my vb program to start automaticaly, not hit a button and my other program shows up.

Thanks for your help!

Is This A Good Question/Topic? 0
  • +

Replies To: Opening/closing external programs

#2 Rexgr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-June 09

Re: Opening/closing external programs

Posted 15 June 2009 - 07:03 PM

Hello warhawk!

I did some research into this myself and came up with this code:
Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim myprocess As Process = System.Diagnostics.Process.Start("C:\Program Files\Internet Explorer\iexplore.exe")
	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("iexplore")

		For Each p As Process In pProcess
			p.Kill()
		Next
	End Sub
End Class




I got this code from you and http://vbnetsample.b...ll-process.html
Hope that solves your problem!

-Rexgr
Was This Post Helpful? 0
  • +
  • -

#3 warhawk  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 42
  • Joined: 22-March 09

Re: Opening/closing external programs

Posted 16 June 2009 - 02:18 PM

Thanks alot!

For the most part, your code worked amazingly! The one flaw was that when it killed the process, it killed my dreamincode.net window also. All internet explorers were closed... Do you think there is a way to single out the recently opened one?

Also is there a way to to link a vb program and a regular program so opening the regular program starts the vb program as well?
Was This Post Helpful? 0
  • +
  • -

#4 camckee316  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 277
  • Joined: 29-August 08

Re: Opening/closing external programs

Posted 05 August 2009 - 10:33 PM

I am also attempting to write a program that will open and close a program. This is for my personal use. I have a limit on my downloads (200MB), execpt from the hours of 1am to 6am. So I would like to have a few programs to run durning that time. This is just a sample program to open.

It opens, several times, but will not close.
How could I get this program to open only once and then close. I want to be able to use the system time to open and close the program.

Public Class Form1
   
	Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
		Dim startnew As System.Diagnostics.ProcessStartInfo
		Dim programstart As New System.Diagnostics.Process


		startnew = New System.Diagnostics.ProcessStartInfo("C:\Dev-Cpp\devcpp.exe")
		programstart.StartInfo = startnew


		tmrlabel.Text = Format(TimeOfDay, "hh:mm:ss")


		If tmrlabel.Text = Format(TimeOfDay, "12:00:00") Then
			'start program

			programstart.Start()

		End If



		If tmrlabel.Text = Format(TimeOfDay, "12:00:30") Then


			'close programs or shut down computer.
			Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("Dev-C++4.9.9.2")


			For Each p As Process In pProcess

				p.Kill()

			Next


		End If
	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Me.Close()

	End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#5 camckee316  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 277
  • Joined: 29-August 08

Re: Opening/closing external programs

Posted 20 August 2009 - 09:37 AM

View Postwarhawk, on 16 Jun, 2009 - 01:18 PM, said:

Thanks alot!

For the most part, your code worked amazingly! The one flaw was that when it killed the process, it killed my dreamincode.net window also. All internet explorers were closed... Do you think there is a way to single out the recently opened one?

Also is there a way to to link a vb program and a regular program so opening the regular program starts the vb program as well?


Thanks you. I am working on the kill process. So far I am still not have any luck. I have a couple more options that I need to try yet though. I have got something similiar that opens another program. I works some what like this one but you browse to file you want to open. It works just as well. If you would like to take a look at it let me know, and I will pm you the code.
Was This Post Helpful? 0
  • +
  • -

#6 Guest_Tomik*


Reputation:

Re: Opening/closing external programs

Posted 08 February 2011 - 05:33 AM

View PostRexgr, on 15 June 2009 - 07:03 PM, said:

Hello warhawk!

I did some research into this myself and came up with this code:
Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim myprocess As Process = System.Diagnostics.Process.Start("C:\Program Files\Internet Explorer\iexplore.exe")
	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("iexplore")

		For Each p As Process In pProcess
			p.Kill()
		Next
	End Sub
End Class




I got this code from you and http://vbnetsample.b...ll-process.html
Hope that solves your problem!

-Rexgr

Was This Post Helpful? 0

Page 1 of 1