From 4afafcd15241167eecae82796fca9dc65efefef4 Mon Sep 17 00:00:00 2001 From: "Alexander E. Patrakov" Date: Sat, 30 Jan 2021 07:33:17 +0500 Subject: [PATCH] Simplify Windows instructions Instead of a Websockify-specific tool that needs to be compiled, and that doesn't work on Windows 10 anyway (the service takes forever to start), let's switch to the industry standard SrvAny tool. This also gets rid of .Net Framework requirement and lets one run modern versions of Websockify easily. --- Windows/Windows Service Readme.md | 61 +++++++++ Windows/Windows Service Readme.txt | 39 ------ .../Program.cs | 24 ---- .../ProjectInstaller.Designer.cs | 61 --------- .../ProjectInstaller.cs | 19 --- .../ProjectInstaller.resx | 129 ------------------ .../Properties/AssemblyInfo.cs | 36 ----- .../Service1.Designer.cs | 37 ----- .../Service1.cs | 41 ------ .../noVNC Websocket.csproj | 75 ---------- .../noVNC Websocket.sln | 20 --- 11 files changed, 61 insertions(+), 481 deletions(-) create mode 100644 Windows/Windows Service Readme.md delete mode 100644 Windows/Windows Service Readme.txt delete mode 100644 Windows/noVNC Websocket Service Project/Program.cs delete mode 100644 Windows/noVNC Websocket Service Project/ProjectInstaller.Designer.cs delete mode 100644 Windows/noVNC Websocket Service Project/ProjectInstaller.cs delete mode 100644 Windows/noVNC Websocket Service Project/ProjectInstaller.resx delete mode 100644 Windows/noVNC Websocket Service Project/Properties/AssemblyInfo.cs delete mode 100644 Windows/noVNC Websocket Service Project/Service1.Designer.cs delete mode 100644 Windows/noVNC Websocket Service Project/Service1.cs delete mode 100644 Windows/noVNC Websocket Service Project/noVNC Websocket.csproj delete mode 100644 Windows/noVNC Websocket Service Project/noVNC Websocket.sln diff --git a/Windows/Windows Service Readme.md b/Windows/Windows Service Readme.md new file mode 100644 index 0000000..069692e --- /dev/null +++ b/Windows/Windows Service Readme.md @@ -0,0 +1,61 @@ +Running Websockify as a Windows service +======================================= + +Installation and configuration +------------------------------ + +Download the following software: + + * Python, from https://www.python.org/downloads/windows/ + * SrvAny, from http://simpleauto.byethost8.com/Zip/SrvAny.zip + +Note that there is [a modern alternative for SrvAny](https://github.com/rwmjones/rhsrvany), +but that project does not provide binaries. + +Install Python for all users, not just the current one. Extract Websockify +into a directory, e.g. `C:\Program Files\websockify`, so that e.g. +`README.md` ends up there. Extract the `SrvAny.zip` archive, copy the +`WIN7\SrvAny.exe` file into `C:\Program Files\websockify`. + +Then create a batch file, `C:\Program Files\websockify\run.bat`, that runs +Websockify from its directory with the correct options under the correct +Python interpreter: + +``` +C: +cd "\Program Files\websockify" +"C:\Program Files\Python39\python.exe" -m websockify 5901 127.0.0.1:5900 +``` + +Run it by hand once so that Windows asks you about a firewall exception. +After confirming the exception, press `Ctrl+C` to terminate the script. + +Then create a Windows service for Websockify (use an Administrator command +prompt for that). For paths with spaces, like in this example, double-escaping +is needed: once for `cmd.exe` and once for `SrvAny.exe`. + +``` +C: +cd "\Program Files\websockify" +SrvAny.exe -install Websockify 10s \\\"C:\Program Files\websockify\run.bat\\\" +``` + +In the Windows Control Panel, under Services, a new "Websockify" service will +appear. In its properties dialog, you can change the startup type, e.g. make +it start automatically at boot. Or, you can start the service manually. + +Uninstallation +-------------- + +If you want to remove the service, first set its startup type to Manual, then +reboot the PC. Then run this command using the Administrator command prompt: + +``` +C: +cd "\Program Files\websockify" +SrvAny.exe -remove Websockify +``` + +After that, you will be able to remove the `C:\Program Files\websockify` +directory completely. + diff --git a/Windows/Windows Service Readme.txt b/Windows/Windows Service Readme.txt deleted file mode 100644 index 2ebd11e..0000000 --- a/Windows/Windows Service Readme.txt +++ /dev/null @@ -1,39 +0,0 @@ ------------------------------------ -Windows noVNC Websockify Service ------------------------------------ - -The "noVNC Websocket Service.exe" file is a windows service wrapper created with Visual Studio 2010 to create a windows service to start stop the noVNC Websocket Server. All files used to create the wrapper can be found in 'noVNC Websocket Service Project' folder. - -To download the precompiled executables please grab the zip in the downloads section of websockify project: -https://github.com/novnc/websockify - ---------------------------- -Installation ---------------------------- - -1. This service requires websockify.exe be in the same directory. Instructions on how to compile websockify python script as a windows executable can be found here: -https://github.com/novnc/websockify/wiki/Compiling-Websockify-as-Windows-Executable - -2.To add this service to a Windows PC you need to run the commandline as administrator and then run this line: - -sc create "noVNC Websocket Server" binPath= "PATH TO noVNC eg C:\noVNC\utils\Windows\Websocket Service.exe" DisplayName= "noVNC Websocket Server" - -3 .Once this is run you will be able to access the service via Control Panel > Admin Tools > Services. In here you can specify whether you want the service to run automatically and start at stop the service. - ---------------------------- -Configuration ---------------------------- -The file noVNCConfig.ini must be in the same directory as "noVNC Websocket Service.exe". - -This file contains a single line which is the websockify.exe statup arguements. An example is: -192.168.0.1:5901 192.168.0.1:5900 - -All websockify supported arguements will work if added here. - ---------------------------- -Deletion ---------------------------- - -You can delete the service at any time by running the commandline as admin and using this command: -sc delete "noVNC Websocket Server". - diff --git a/Windows/noVNC Websocket Service Project/Program.cs b/Windows/noVNC Websocket Service Project/Program.cs deleted file mode 100644 index 2d07c33..0000000 --- a/Windows/noVNC Websocket Service Project/Program.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.ServiceProcess; -using System.Text; - -namespace MELT_Command_Websocket -{ - static class Program - { - /// - /// The main entry point for the application. - /// - static void Main() - { - ServiceBase[] ServicesToRun; - ServicesToRun = new ServiceBase[] - { - new Service1() - }; - ServiceBase.Run(ServicesToRun); - } - } -} diff --git a/Windows/noVNC Websocket Service Project/ProjectInstaller.Designer.cs b/Windows/noVNC Websocket Service Project/ProjectInstaller.Designer.cs deleted file mode 100644 index 3dab5bb..0000000 --- a/Windows/noVNC Websocket Service Project/ProjectInstaller.Designer.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace MELT_Command_Websocket -{ - partial class ProjectInstaller - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller(); - this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller(); - // - // serviceProcessInstaller1 - // - this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.NetworkService; - this.serviceProcessInstaller1.Installers.AddRange(new System.Configuration.Install.Installer[] { - this.serviceInstaller1}); - this.serviceProcessInstaller1.Password = null; - this.serviceProcessInstaller1.Username = null; - // - // serviceInstaller1 - // - this.serviceInstaller1.Description = "noVNC Websocket Service"; - this.serviceInstaller1.DisplayName = "noVNC Websocket Service"; - this.serviceInstaller1.ServiceName = "noVNC Websocket Service"; - this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic; - // - // ProjectInstaller - // - this.Installers.AddRange(new System.Configuration.Install.Installer[] { - this.serviceProcessInstaller1}); - - } - - #endregion - - private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1; - private System.ServiceProcess.ServiceInstaller serviceInstaller1; - } -} \ No newline at end of file diff --git a/Windows/noVNC Websocket Service Project/ProjectInstaller.cs b/Windows/noVNC Websocket Service Project/ProjectInstaller.cs deleted file mode 100644 index 783bb15..0000000 --- a/Windows/noVNC Websocket Service Project/ProjectInstaller.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Configuration.Install; -using System.Linq; - - -namespace MELT_Command_Websocket -{ - [RunInstaller(true)] - public partial class ProjectInstaller : System.Configuration.Install.Installer - { - public ProjectInstaller() - { - InitializeComponent(); - } - } -} diff --git a/Windows/noVNC Websocket Service Project/ProjectInstaller.resx b/Windows/noVNC Websocket Service Project/ProjectInstaller.resx deleted file mode 100644 index fbda1ae..0000000 --- a/Windows/noVNC Websocket Service Project/ProjectInstaller.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 56 - - - 196, 17 - - - False - - \ No newline at end of file diff --git a/Windows/noVNC Websocket Service Project/Properties/AssemblyInfo.cs b/Windows/noVNC Websocket Service Project/Properties/AssemblyInfo.cs deleted file mode 100644 index 832319e..0000000 --- a/Windows/noVNC Websocket Service Project/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("MELT Command Websocket")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("MELT Command Websocket")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5ab831cb-6852-4ce1-849c-b26725b0e10b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Windows/noVNC Websocket Service Project/Service1.Designer.cs b/Windows/noVNC Websocket Service Project/Service1.Designer.cs deleted file mode 100644 index c569eca..0000000 --- a/Windows/noVNC Websocket Service Project/Service1.Designer.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace MELT_Command_Websocket -{ - partial class Service1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - this.ServiceName = "Service1"; - } - - #endregion - } -} diff --git a/Windows/noVNC Websocket Service Project/Service1.cs b/Windows/noVNC Websocket Service Project/Service1.cs deleted file mode 100644 index ce94bf6..0000000 --- a/Windows/noVNC Websocket Service Project/Service1.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.ServiceProcess; -using System.Text; -using System.IO; - -namespace MELT_Command_Websocket -{ - public partial class Service1 : ServiceBase - { - Process websockify; - public Service1() - { - InitializeComponent(); - } - - protected override void OnStart(string[] args) - { - - string configpath = AppDomain.CurrentDomain.BaseDirectory + "\\noVNCConfig.ini"; - string sockifypath = AppDomain.CurrentDomain.BaseDirectory + "\\websockify.exe"; - //Load commandline arguements from config file. - StreamReader streamReader = new StreamReader(configpath); - string arguements = streamReader.ReadLine(); - streamReader.Close(); - - //Start websockify. - websockify = System.Diagnostics.Process.Start(sockifypath, arguements); - } - - protected override void OnStop() - { - //Service stopped. Close websockify. - websockify.Kill(); - } - } -} diff --git a/Windows/noVNC Websocket Service Project/noVNC Websocket.csproj b/Windows/noVNC Websocket Service Project/noVNC Websocket.csproj deleted file mode 100644 index 368d183..0000000 --- a/Windows/noVNC Websocket Service Project/noVNC Websocket.csproj +++ /dev/null @@ -1,75 +0,0 @@ - - - - Debug - x86 - 8.0.30703 - 2.0 - {6B86AE7B-6BBD-4E74-8802-5995E8B6D27D} - WinExe - Properties - noVNC_Websocket_Service - noVNC Websocket Service - v3.5 - 512 - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - x86 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - Component - - - ProjectInstaller.cs - - - Component - - - Service1.cs - - - - - - - ProjectInstaller.cs - - - - - \ No newline at end of file diff --git a/Windows/noVNC Websocket Service Project/noVNC Websocket.sln b/Windows/noVNC Websocket Service Project/noVNC Websocket.sln deleted file mode 100644 index 140de1b..0000000 --- a/Windows/noVNC Websocket Service Project/noVNC Websocket.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "noVNC Websocket", "noVNC Websocket.csproj", "{6B86AE7B-6BBD-4E74-8802-5995E8B6D27D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6B86AE7B-6BBD-4E74-8802-5995E8B6D27D}.Debug|x86.ActiveCfg = Debug|x86 - {6B86AE7B-6BBD-4E74-8802-5995E8B6D27D}.Debug|x86.Build.0 = Debug|x86 - {6B86AE7B-6BBD-4E74-8802-5995E8B6D27D}.Release|x86.ActiveCfg = Release|x86 - {6B86AE7B-6BBD-4E74-8802-5995E8B6D27D}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal