Results 1 to 2 of 2

Thread: service and "Allow service interact with desktop"

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    99

    Question service and "Allow service interact with desktop"

    Hi guys...

    I have created a win service with icon.

    Icon is displayed only if : Allow service interact with desktop.
    Is there a way to avoid to set the "Allow service interact with desktop" manually and to do it programmatically with vb.net o during setup?

    thank for any suggestions


  2. #2
    Lively Member
    Join Date
    Oct 2005
    Posts
    123

    Re: service and "Allow service interact with desktop"

    Hi i had the same problem. U can set it programatically with the following code:
    (After installing the event ServiceInstaller1_Committed will rise and set the option to "Allow service interact with desktop" )

    Imports System.ComponentModel
    Imports System.Configuration.Install
    Imports System.Management

    Private Sub ServiceInstaller1_Committed(ByVal sender As Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles ServiceInstaller1.Committed
    Dim coOptions As New ConnectionOptions

    coOptions.Impersonation = ImpersonationLevel.Impersonate

    Dim mgmtScope As ManagementScope = New ManagementScope("root\CIMV2", coOptions)

    mgmtScope.Connect()

    Dim wmiService As ManagementObject

    wmiService = New ManagementObject("Win32_Service.Name='" + Me.ServiceInstaller1.ServiceName + "'")

    Dim InParam As ManagementBaseObject = wmiService.GetMethodParameters("Change")


    InParam("DesktopInteract") = True

    Dim OutParam As ManagementBaseObject = wmiService.InvokeMethod("Change", InParam, Nothing)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width