• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

Running an Aplication on a remote computer.

Hi All, Im prity sure this has been asked before but the sample that I used didn't work.  Basicly what I need is some code that could keep track of running applications on a specified computer and if the application stopped running for what ever reason would restart it. The code that I used was,

Private Sub ExecProg(ServerName As String, ProgramName As String)
Dim process As Object, processid As Long, result As Long

Set process = GetObject("WinMgmts:{impersonationLevel=Impersonate, authenticationLevel=pktPrivacy}\\" & ServerName & "\root\cimv2:Win32_Process")

result = process.Create(ProgramName, Null, Null, processid)

If result = 0 Then
 MsgBox "Command executed successfully on remote machine", vbInformation
Else
 MsgBox "Some error, could not execute command", vbExclamation
End If
End Sub

but it only show's up as a process running not an application. Please help! sorry if I've not explained it very well.
0
alexw1983
Asked:
alexw1983
  • 2
  • 2
  • 2
  • +1
1 Solution
 
Richie_SimonettiIT OperationsCommented:
hearing...
0
 
alexw1983Author Commented:
OK I'll try again :)

I'm developing an application that shows me when a user is logged into their computer. The application then records the results to a SQL Server which has been done.  The problem I'm having is sometimes the application stops running.  I've used abit of code were I can see what applications are running on a remote computer, but the code that I have for starting application wouldn't relaunch my application, showing the form etc. is their a way I can do this?

Many Thanks in advance.
0
 
RainUKCommented:
In what way does the app stop running, I mean if the user logs off, then the app will die. Unless you set it to persist. Bit confused though as to your actual problem. Applications don't just stop running.... can you put in some sort of logging code?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
irfanazamCommented:
Hi,

i think it is very simple.

1). start a Vb project.
2). place a timer control on form.
3). set timer interval as your choice.
4). in timer event of timer control do the followigns:-
    a). use FindWindow Api to find the application window you want to check
    b). if api return you some window handle mean a positive value then it means that application you are looking for is running. but if it returns 0 then it means application is stopped.
    c). if you find that application is stopped use Shell statement to run the application you want to restart.

hope it will work for you. i personally have used this technique supervise an application and to restart it in the case it is stopped. you will implement it easily if you can use FindWindow Api.

if you feel problem then i can send you a working example.

Happy Coding,
Muhammad Irfan Azam
0
 
alexw1983Author Commented:
Thanks good idea! as you can guess I'm pritty new to experts exchange!
0
 
Richie_SimonettiIT OperationsCommented:
Ok. You are new to EE. Try to read the guidelines regarding accept comments again since if it is a good idea AND solves your problem, nothing but an "A" grade would be enougth.
Welcome and cheers
0
 
irfanazamCommented:
Thank you alexw1983 for accepting my answer. this was my first answer on experts exchange.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now