1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Diagnostics;
6 using System.Linq;
7 using System.ServiceProcess;
8 using System.Text;
9 using System.IO;
10 
11 namespace MELT_Command_Websocket
12 {
13     public partial class Service1 : ServiceBase
14     {
15         Process websockify;
Service1()16         public Service1()
17         {
18             InitializeComponent();
19         }
20 
OnStart(string[] args)21         protected override void OnStart(string[] args)
22         {
23 
24             string configpath = AppDomain.CurrentDomain.BaseDirectory + "\\noVNCConfig.ini";
25             string sockifypath = AppDomain.CurrentDomain.BaseDirectory + "\\websockify.exe";
26             //Load commandline arguements from config file.
27             StreamReader streamReader = new StreamReader(configpath);
28             string arguements = streamReader.ReadLine();
29             streamReader.Close();
30 
31             //Start websockify.
32             websockify = System.Diagnostics.Process.Start(sockifypath, arguements);
33         }
34 
OnStop()35         protected override void OnStop()
36         {
37             //Service stopped. Close websockify.
38             websockify.Kill();
39         }
40     }
41 }
42