C # by default, no interactive interface is provided when a windows service is created. Neither form nor console can be displayed. However, you can enable desktop interaction in the service to start >>> run >> services. msc> select your windows Service> right-click Properties> log on> select allow services to interact with the desktop. In addition, you can add the AfterInstall Event Response to the service installer:
Private void serviceInstaller_AfterInstall (object sender, InstallEventArgs e)
{
Setserviceappstopinsteract (this. serviceInstaller. ServiceName );
}
/// <Summary>
/// Allow service interface Interaction
/// </Summary>
/// <Param name = "serviceName"> </param>
Private void setserviceappstopinsteract (string serviceName)
{
ManagementObject wmiService = new ManagementObject (string. Format ("Win32_Service.Name = {0}", serviceName ));
ManagementBaseObject changeMethod = wmiService. GetMethodParameters ("Change ");
ChangeMethod ["Publish topinteract"] = true;
ManagementBaseObject OutParam = wmiService. InvokeMethod ("Change", changeMethod, null );
}