Saleem
Saleem

Reputation: 730

How to keep program running on VPS even after it's closed?

I want to apologize for the question I'm going to ask if it's not clear and detailed enough. I delivered a program (developed using VB.Net) to an online client, it's an automation program that simulates user keystrokes (using SendKeys) on a windows OS. All went well, but he said that when he runs the program on VPS, program closes when he closes VPS, although other programs keep running.

I hope someone here can help me with explaining to me the reason behind this issue, and if there's any fix for it. The problem is that I don't have access to the client's VPS since he's an online client.

Thanks in advance.

UPDATE: I got access to client's VPS, program throw an exception when connection to VPS is closed, exception message: System.Windows.Forms.MouseEventArgs

Upvotes: 0

Views: 5718

Answers (1)

MattSizzle
MattSizzle

Reputation: 3175

This is due to the remote desktop connection to the Windows VPS. When the user logs off the remote connection the .EXE / Application is halted and will no longer run. To work around this you can do one of the following:

  1. Create a new Windows Service Project from the New Project button in the Visual Studio, and then just program your application as a service. Linked Here

  2. Use the Service management Window within the VPS environment and add the executable file of your program. It will start running as a service, (with visible windows and everything as you coded it) and will run when the user logs out. Linked Here

  3. Use the Task Manager to schedule a task that will run the executable file on certain conditions (like system startup). Linked Here

If it is something run by multiple clients I would use option 1 as it provides portability and easy of deployment. It will most likely require a refactor in someway or another though.

If it is a single use application and will not be used by anyone else, but is going to be a constant presence on the VPS then I would use option 2.

I would only use option 3 if you need further control over the conditions in which the script runs.

Hope this helps..

Upvotes: 1

Related Questions