Papercut-SMTP icon indicating copy to clipboard operation
Papercut-SMTP copied to clipboard

Service Installation Steps

Open microalps opened this issue 7 months ago • 2 comments

Describe the bug Documentation leads on to https://github.com/ChangemakerStudios/Papercut-SMTP/blob/develop/src/Papercut.Service/Readme.md for steps to install as a service. Latest version does not respond to CLI parameters so install --help -h all start the service instead.

To Reproduce Steps to reproduce the behavior:

  1. Download the ZIP with the service
  2. Unzip to a folder
  3. Try the documented CLI

Expected behavior A clear and concise set of steps to install the service to windows services.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows
  • Version: 7.0.1

Related to #278

microalps avatar May 19 '25 17:05 microalps

FYI : I attempted to follow Microsoft's steps hoping that it might help - but the first line of code Console.Title = AppMeta.AppName; triggers an exception

Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.IOException: The handle is invalid. at System.ConsolePal.set_Title(String value) at Papercut.Service.Program.Main(String[] args) in C:\projects\papercut-smtp\src\Papercut.Service\Program.cs:line 42 at Papercut.Service.Program.<Main>(String[] args)

Seems like this was never tested as a windows 'service'

microalps avatar May 19 '25 18:05 microalps

100% a problem. Some of the documentation about installing as a service is wrong too.

The easiest way to install is with either sc.exe or with the New-Service powershell cmdlet.

The fix to the code is maybe pretty trivial.

I think you just need to do something like:

if (Environment.UserInteractive)
{
    Console.Title = AppMeta.AppName;    
 }

And providing there are no more direct references to Console it will probably happily run as a service. I'll check this and report back :-)

ian-gratton-citation avatar May 27 '25 16:05 ian-gratton-citation

Confirmed this is fixed in the latest build. Thanks @ian-gratton-citation for pointing me at the issue.

Jaben avatar Oct 09 '25 07:10 Jaben