Skip to content

Instantly share code, notes, and snippets.

@Phillip-C
Created April 27, 2018 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phillip-C/ac76e96a4798fc729c8f47f374c47b00 to your computer and use it in GitHub Desktop.
Save Phillip-C/ac76e96a4798fc729c8f47f374c47b00 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace WindowsService1
{
public partial class VulnService : ServiceBase
{
public VulnService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
LogService("Service is Started");
}
protected override void OnStop()
{
LogService("Service Stoped");
}
private void LogService(string content)
{
FileStream fs = new FileStream(@"c:\VulnServiceLog.txt", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine(content);
sw.Flush();
sw.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment