Windows service problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pakmarshal
    New Member
    • Aug 2009
    • 17

    Windows service problem

    I am working on a Windows Service application in VB.net 2008. The main objective of the application is to monitor starting and stopping of applications listed in a file. I build the service as system level by using ‘System’ user account. I used “Management.Man agementEventWat cher” class to get event handlers for starting and stopping of processes. I used following code to set process arrived event

    mManagementStar tWatcher = New ManagementEvent Watcher("Select * From Win32_ProcessSt artTrace")
    AddHandler mManagementStar tWatcher.EventA rrived, AddressOf ManagementWatch er_StartEventAr rived
    This works fine as whenever a process is launched in the computer it raises the event routine “ManagementWatc her_StartEventA rrived”. Now the problem I am facing is, whenever I starts/stops my service multiple times it stops raising “ManagementWatc her_StartEventA rrived” event. It remain as it is even if I restart my service and also start it after unistalling and installing (using sc.exe and installutil). This starts working only when I restarts my computer.

    My service executeable handles ‘-i/-u’ arguments to self install/uninstall. I used following code to install/uninstall

    Dim ArgString As String()

    ' Set arguments to install/uninstall service

    If InstallSrv Then
    ArgString = New String() {"/LogFile=", SrvExePath}
    Else
    ArgString = New String() {"/u", "/LogFile=", SrvExePath}
    End If

    ' Install/uninstall service

    Call ManagedInstalle rClass.InstallH elper(ArgString )

    Please guide me in this regard.

    Thanks and Regards,

    Maverick.
Working...