By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

Windows service problem

Pakmarshal
P: 17
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.ManagementEventWatcher” class to get event handlers for starting and stopping of processes. I used following code to set process arrived event

mManagementStartWatcher = New ManagementEventWatcher("Select * From Win32_ProcessStartTrace")
AddHandler mManagementStartWatcher.EventArrived, AddressOf ManagementWatcher_StartEventArrived
This works fine as whenever a process is launched in the computer it raises the event routine “ManagementWatcher_StartEventArrived”. Now the problem I am facing is, whenever I starts/stops my service multiple times it stops raising “ManagementWatcher_StartEventArrived” 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 ManagedInstallerClass.InstallHelper(ArgString)

Please guide me in this regard.

Thanks and Regards,

Maverick.
Sep 8 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.