Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 552501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:30:23+00:00 2026-05-13T11:30:23+00:00

I am writing a C# application that, among other things, automatically closes the advertisement

  • 0

I am writing a C# application that, among other things, automatically closes the advertisement a certain game displays after the user exits the game. My program accomplishes this by killing the game process when it detects that the user has exited the game. My program is similar to an Autohotkey script written by someone else that does similar things but it adds some features and a GUI.

Naturally, I used the Process.Kill method. However, that would fail with an “Access is denied” exception. I noticed that the Autohotkey script uses an unusual method of killing the process. I asked the author about it, and he said that he too had trouble killing the process with normal methods.

We suspect the reason normal process termination methods do not work is the HackShield software the game uses to attempt to combat cheating.

Here is the Autohotkey code the other guy’s script uses for killing a process:

; kills all process instances of a given executable name
; COM AutoHotkey library code omitted
KillProcessInstances(exe)
{
  psvc := COM_GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
  pset := COM_Invoke(psvc, "ExecQuery", "Select * from Win32_Process Where Name = '" exe "'")
  penm := COM_Invoke(pset, "_NewEnum")
  Loop, % COM_Invoke(pset, "Count")
    If COM_Enumerate(penm, pobj)=0
    {
      COM_Invoke(pobj, "Terminate")
      COM_Release(pobj)
    }
  COM_Release(penm)
  COM_Release(pset)
  COM_Release(psvc)
}

I replaced the Process.KIll with the WMI calls in my program using the System.Management namespace and my program is now able to kill the process.

What I don’t understand is what makes the WMI any different from Process.Kill. I would expect both to work or both to fail. In addition, Task Manager is able to kill the process just fine, but I would think it just uses a TerminateProcess win32 call just as Process.Kill surely does. Can anyone shed some light on the cause of the different behavior? If it matters, I’m running Windows XP.

Edit: wj32 explained why the WMI works, but can anyone explain why I can kill the process with Task Manager but not with my own program?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:30:24+00:00Added an answer on May 13, 2026 at 11:30 am

    WMI calls are not performed within the security context of your process. They are handled in another process (I’m guessing the Winmgmt service). This service runs under the SYSTEM account, and HackShield may be allowing the termination continue due to this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an application that if the user hits back, it may resend
I'm writing a C++ static library that needs to be shared among several applications,
im writing an application that downloads and installs addons for programs which needs to
I am writing an application that downloads large files in the background. All clients
I'm writing an application that on some stage performs low-level disk operations in Linux
I am writing an application that needs to bring window of an external app
I'm writing an application that is basically just a preferences dialog, much like the
I am current writing an application that will require multiple inserts, updates and deletes
Say you are writing an application that must implement the HTTP protocol. Protocols are
I'm writing an application that uses renaming rules to rename a list of files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.