Forcing Dr. Watson via WMI from asp.net web app

  • Thread starter Thread starter Dr. StrangeDub
  • Start date Start date
D

Dr. StrangeDub

I'm looking for a way to force a service to take Dr. Watson dump and
terminate from within an asp.net web application (in C#).

A bit of background: I am try to code a web/WMI equivalent to an
existing C++ utility that we developed to force a Dr. Watson. The C++
version simply uses --
HRESULT result = ControlService( hService, command, &status );
where command is set to 128.
I figured I could simply call the Win32_BaseService.UserControlService
(WMI) and pass in 128 (type byte) for the control code. This returns a
error status = 21, which is Invalid Parameter.

Is the UserControlService simply catching the case where an undefined
user control code is passed in, whereas ControlService takes an
exception in the same case? If so, what's an alternative way to force
a Dr. Watson from C#? If not, do you have any idea what I may be
doing wrong?

Any and all help, or links to possible answers, greatly appreciated.

-Michael Rose
Unisys Corp.
 
A colleague of mine came up with a very simple answer:

string serviceName = "someservicename";
System.ServiceProcess.ServiceController sc = null;
sc = new System.ServiceProcess.ServiceController( serviceName );

if( sc != null )
{
try
{
sc.ExecuteCommand( 128 );
}
catch( System.Exception e )
{
System.Console.WriteLine( "Exception " + e.Message );
}
}

Note that in order to get this to compile, you'll need to add a
reference that includes the namespace System.ServiceProcess, which can
be found in the .NET component System.ServiceProcess.dll.

One note: as this is not using WMI it will only kill services on the
local machine -- that is, where the web is hosted.

Michael Rose
-Unisys Corp.
 
A colleague of mine came up with a very simple answer:

string serviceName = "someservicename";
System.ServiceProcess.ServiceController sc = null;
sc = new System.ServiceProcess.ServiceController( serviceName );

if( sc != null )
{
try
{
sc.ExecuteCommand( 128 );
}
catch( System.Exception e )
{
System.Console.WriteLine( "Exception " + e.Message );
}
}

Note that in order to get this to compile, you'll need to add a
reference that includes the namespace System.ServiceProcess, which can
be found in the .NET component System.ServiceProcess.dll.

One note: as this is not using WMI it will only kill services on the
local machine -- that is, where the web is hosted.

Michael Rose
-Unisys Corp.

==================
 
Back
Top