6 Replies - 1220 Views - Last Post: 23 July 2009 - 11:26 AM Rate Topic: -----

#1 AmuletOfNight  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 153
  • Joined: 23-July 09

Checking if a programs is closed and shut down computer?

Post icon  Posted 23 July 2009 - 08:30 AM

Hello, I'm making a simple app that checks if Windows Media Center is open, if it is open and the program receives the close command from windows, make my application shut down the computer. I was wondering if this was the most efficient way of doing this:

One timer on the forum

Timer code:
	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		For Each Center As Process In Process.GetProcessesByName("ehshell")
			If Center.HasExited = True Then
				Shell("shutdown -s")
			Else

			End If
		Next
	End Sub


and the Timer is started apon start

Timer1.Start


Thank you!

PS: I also cannot get the application to hide form the user so they cannot close it. What could be preventing this? I'm using
Me.Hide

This post has been edited by AmuletOfNight: 23 July 2009 - 08:32 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Checking if a programs is closed and shut down computer?

#2 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1002
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Checking if a programs is closed and shut down computer?

Posted 23 July 2009 - 08:43 AM

Your best bet would be to use your code within a Windows Service, then they can't close it (unless they have admin access and/or leet skills).

EDIT: But yes, that's how I'd do it.

This post has been edited by MageUK: 23 July 2009 - 08:43 AM

Was This Post Helpful? 0
  • +
  • -

#3 AmuletOfNight  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 153
  • Joined: 23-July 09

Re: Checking if a programs is closed and shut down computer?

Posted 23 July 2009 - 09:32 AM

Could you please explain the Windows Services and how to integrate my application into it? Thanks!
Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1002
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Checking if a programs is closed and shut down computer?

Posted 23 July 2009 - 09:33 AM

Erm, you make your own.

It's a project type within VS.
Was This Post Helpful? 0
  • +
  • -

#5 AmuletOfNight  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 153
  • Joined: 23-July 09

Re: Checking if a programs is closed and shut down computer?

Posted 23 July 2009 - 11:07 AM

I only have

"Windows Form Application"
"Class Library"
"WPF Application"
"WPF Browser Application"
and
"Console Application"

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

#6 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1002
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Checking if a programs is closed and shut down computer?

Posted 23 July 2009 - 11:08 AM

Oh... I guess you're using Express?

In that case you could create a "fake" Windows Forms application, and just not call Application.Run, then they don't have a window to close ;)
Was This Post Helpful? 0
  • +
  • -

#7 AmuletOfNight  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 153
  • Joined: 23-July 09

Re: Checking if a programs is closed and shut down computer?

Posted 23 July 2009 - 11:26 AM

View PostMageUK, on 23 Jul, 2009 - 10:08 AM, said:

Oh... I guess you're using Express?

In that case you could create a "fake" Windows Forms application, and just not call Application.Run, then they don't have a window to close ;)

How do I make it so it does not call Application.Run? I am so noob at this :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1