1

Each time my Windows service (developed in C#, Visual Studio 2010) is installed on a system running Windows 7 or Windows Server 2008 R2, the system error 7030 is logged. The service is not configured to be interactive. The custom Installer sub-class I have created sets the account type to NetworkService:

private System.ServiceProcess.ServiceProcessInstaller _serviceProcessInstaller;
private System.ServiceProcess.ServiceInstaller _serviceInstaller;

public ProjectInstaller()
{
    InitializeComponent();
}

private void InitializeComponent()
{
    _serviceProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
    _serviceInstaller = new System.ServiceProcess.ServiceInstaller();
    _serviceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.NetworkService;
    _serviceProcessInstaller.Password = null;
    _serviceProcessInstaller.Username = null;

    _serviceInstaller.ServiceName = Resources.ServiceName;
    _serviceInstaller.Description = Resources.ServiceDescription;
    _serviceInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;

    Installers.AddRange(new Installer[]
                            {
                               _serviceProcessInstaller,
                               _serviceInstaller
                            });
}

I have also tried setting the Account type to LocalSystem, but error 7030 is logged in this case as well.

In the same Installer subclass I have also tried to unset the registry entry based on How can I configure my windows service in the code to access the desktop?:

    /// <summary>
    /// Override OnCommitted() to overwrite the value of Interactive to be false.
    /// </summary>
    /// <remarks>
    /// See https://stackoverflow.com/questions/1945529/how-can-i-configure-my-windows-service-in-the-code-to-access-the-desktop
    /// </remarks>
    /// <param name="savedState"></param>
    protected override void OnCommitted(System.Collections.IDictionary savedState)
    {
        const string pathToKey = @"SYSTEM\CurrentControlSet\services\MyService.exe";
        const string type = "Type";

        using (var registryKey = Registry.LocalMachine.OpenSubKey(pathToKey, true))
        {
            if (registryKey != null && registryKey.GetValue(type) != null)
            {
                registryKey.SetValue(type, (((int)registryKey.GetValue(type) & ~0x100)));
            }
        }

        base.OnCommitted(savedState);
    }

Neither of these two fix attempts has worked. I have also looked at the following on SO: Alternative to "Allow service to interact with desktop"? and How to set "interact with desktop" in windows service installer.

Community
  • 1
  • 1
Mark West
  • 11
  • 3

0 Answers0