Create a Windows Service Project and set the attributes of the installation program.
Protected override void onstart (string [] ARGs)
{
Using (streamwriter Sw = new streamwriter (@ "F: \ text.txt", true, encoding. getencoding ("gb2312 "))){
Sw. Write ("Start Time:" + datetime. Now. tostring () + "\ t \ n ");
}
}
Protected override void onstop ()
{
Using (streamwriter Sw = new streamwriter (@ "F: \ text.txt", true, encoding. getencoding ("gb2312 ")))
{
Sw. Write ("End Time:" + datetime. Now. tostring () + "\ t \ n ");
}
}
Write something inside and generate it,
In the command
CD to the C: \ WINDOWS \ Microsoft. NET \ framework \ v4.0.30319 file.
Run the instaallutil command,
Install the installation directory of the Windows Service installutil.exe Windows Service (package windowsservice1.exe) <D: \ website \ windowsservice2 \ windowsservice2 \ bin \ debug \ windowsservice1.exe>
Uninstall the directory of the Windows Service installutil.exe/u Windows service item (package windowsservice1.exe)
It's easy,