How to close the windows application through the windows service

naresh

Active member
Joined
Jul 4, 2006
Messages
38
Programming Experience
1-3
Hi,
I am working with the windows service to invoke the application say example.exe. I am invoking the application with the code in windows service System.Diagnosis.process.start("example.exe"). i have taken the simple application in vb6.o the code is just this i written in the button click

me.hide

when i run the service the application will be opend. when i click the button the form is hidden and does not appear anywhere except in the task bar. when i stop the service the application is not getting closed. I need to close the application along with the service. Any help regarding this makes me happy.

thanks and regards ,
Jose.
 
try something like this

VB.NET:
Dim mProccess As New System.Diagnostics.Process
 mProccess = System.Diagnostics.Process.Start("example.exe")
...
mProccess.Kill()

I'm not sure how safe that will be but if the exe isn't doing to much it should be fine.
g
 
Thanks Da its working

I have one more Question about this can u show the user interface of the application through the coding in service. I have one option going to the services -> rightclick the service -> properties -> log on and selecting the the check box of allow service to interact with the desk then the application is coming other wise it exits in the processes.

if you can help in coding i will be the most impressive person
 
I'm not 100% sure what you mean by showing the user interface through the coding. If you wanted to edit settings (If there normally in the popup menu etc...) in the example.exe you could use the args section of the start.

VB.NET:
dim args as String = {arg1,arg2,etc}
Process = System.Diagnostics.Process.Start("example.exe", args)

you would have to edit the example.exe to use these arguments
(For form Application)


VB.NET:
 Shared Sub main(ByVal CmdArgs() As String)
        Dim form As New Form1 ' Initalizes all the global components plus any init 
        form.Label1.Text = CmdArgs(0) ' set all args you wish here
        Application.Run(form) ' make the form appear

    End Sub

g
 
Back
Top