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

Discussion in 'ASP .Net' started by Dr. StrangeDub, Oct 1, 2003.

  1. 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.
     
    Dr. StrangeDub, Oct 1, 2003
    #1
    1. Advertising

  2. 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.


    On Wed, 01 Oct 2003 13:45:27 -0500, Dr. StrangeDub
    <> wrote:

    >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.
     
    Dr. StrangeDub, Oct 3, 2003
    #2
    1. Advertising

  3. 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.

    ==================
    On Wed, 01 Oct 2003 13:45:27 -0500, Dr. StrangeDub
    <> wrote:

    >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.
     
    Dr. StrangeDub, Oct 3, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hazzard
    Replies:
    5
    Views:
    323
    Steven Cheng[MSFT]
    Apr 15, 2004
  2. Replies:
    0
    Views:
    480
  3. Greg B
    Replies:
    3
    Views:
    874
  4. =?iso-8859-1?q?Lars_Bj=F8nnes?=
    Replies:
    1
    Views:
    433
    =?iso-8859-1?q?Lars_Bj=F8nnes?=
    Oct 16, 2003
  5. Pete

    WMI security via ASP.NET app

    Pete, May 4, 2006, in forum: ASP .Net Security
    Replies:
    6
    Views:
    224
Loading...

Share This Page