Active Windows/Applications

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to no avail, to create a program that every once in a while checks to see if another program is active. When it finds it isn't, it will make it active using the Shell command.

VB 6.0 used to have it available by calling using the Win32 but I cant find the source.

Thanks in advance.
 
Try something like this code.
Public Function ProcessIsExecuting(ByVal szFile As String) As Boolean

Dim p As Process

Dim aProcName As String = Path.GetFileNameWithoutExtension(szFile)

If Process.GetProcessesByName(aProcName).Length >= 1 Then

Return True

Else

Return False

End If

End Function

Private Sub StartMyApp()

If not ProcessIsExecuting(myApp) then

Dim newProcess As New Process

newProcess.StartInfo = New
System.Diagnostics.ProcessStartInfo(myApp.Name)

newProcess.Start()

End IF



I am trying to no avail, to create a program that every once in a while
checks to see if another program is active. When it finds it isn't, it will
make it active using the Shell command.
 
Thank you very much Steven, that will do it. I knew something had to exist but had spent about an hour looking for a solution and didn't find anything that pointed to Process object.
 
np. You might want to remove the artifact in ProcessIsExecuting.

memHog said:
Thank you very much Steven, that will do it. I knew something had to
exist but had spent about an hour looking for a solution and didn't find
anything that pointed to Process object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top