Change the Windows Service Type to be Interactive with Descktop While Setup

The Following Code Should be added to the Service installer after the install is Committed:

    Protected Overrides Sub OnCommitted(ByVal savedState As System.Collections.IDictionary)
        MyBase.OnCommitted(savedState)


        Dim myController As New ServiceController(“yourServiceName”)
        myController.Start()
        myController.Close()


        ‘ Here is where we set the bit on the value in the registry. 
        ‘ Grab the subkey to our service 
        Dim ckey As RegistryKey = Registry.LocalMachine.OpenSubKey(“SYSTEM\CurrentControlSet\Services\ yourServiceName”, True)
        ‘ Good to always do error checking! 
        If ckey IsNot Nothing Then
            ‘ Ok now lets make sure the “Type” value is there, and then do our bitwise operation on it. 
            If ckey.GetValue(“Type”) IsNot Nothing Then
                ckey.SetValue(“Type”, (CInt(ckey.GetValue(“Type”)) Or 256))
            End If
        End If


    End Sub

Advertisements

Posted on January 4, 2010, in How To, VB.NET. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: