?
Solved

Running an Aplication on a remote computer.

Posted on 2003-03-05
7
Medium Priority
?
174 Views
Last Modified: 2010-05-01
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
Comment
Question by:alexw1983
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8072719
hearing...
0
 

Author Comment

by:alexw1983
ID: 8072834
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
 
LVL 5

Expert Comment

by:RainUK
ID: 8074205
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
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!

 
LVL 1

Accepted Solution

by:
irfanazam earned 600 total points
ID: 8074659
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
 

Author Comment

by:alexw1983
ID: 8079269
Thanks good idea! as you can guess I'm pritty new to experts exchange!
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8079367
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
 
LVL 1

Expert Comment

by:irfanazam
ID: 8086109
Thank you alexw1983 for accepting my answer. this was my first answer on experts exchange.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question