views:

96

answers:

4

I want to kill an executable of a game named KnightOnline and deny user to run it. I'm using:

Process.Start("taskkill.exe", "/f /im kol.exe");

but it's showing a command window. How can I hide the command window, or is there another professional but infamous method to deny an unwanted program?

EDIT: I edited hosts and blocked login page of the game as a solution.

+4  A: 

A professional way is to let the user know that some running program may pose conflicts and ask the user to close it before proceeding.

Killing it in silent without even saying "We apologize" is evil.

Developer Art
Maybe it is :). But my little brother must not know I'm making his game not to work.
HasanGursoy
Something is gravely wrong in your relationships...
Developer Art
@Developer Art: When I and my sister were younger, we used to prank each other in similar (albeit low-tech) ways - removing the mouse ball, hiding the power cord, swapping around the keyboard keys etc. I'd say this is borderline evil, yes. I demand...a million dollars! *mwa ha ha ha ha!* `</evil>`
Piskvor
+2  A: 

You can use Process.Kill to kill another process:

foreach (var process in Process.GetProcessesByName("kol"))
{
    process.Kill();
}
Quartermeister
+1  A: 

Try this if you want to run some process in a hidden window:

var processInfo = new ProcessStartInfo() 
                      { 
                         Arguments = "/f /im kol.exe", 
                         FileName = "taskkill.exe", 
                         WindowStyle = ProcessWindowStyle.Hidden 
                      };

Process.Start(processInfo );
ŁukaszW.pl
+4  A: 

Would it be better not to allow the user to start the program in the first place?

Windows 2000 and up (XP, Vista, "Seven") have Software Restriction Policies - allows you to set a whitelist or blacklist of programs. In case of a whitelist, only the listed programs will be allowed to start, whereas with the blacklist, all except the listed programs will be allowed. This check happens at the OS level, and cannot be bypassed (except by Administrators). See e.g. this for examples.

(a blacklist is pretty ineffective, as renaming the executable allows running it again; whitelist is more work to get correct and to manage - but most users need at most 20 apps, plus system services)

Note: not all versions of Windows allow the administrators to set Group Policies, IIRC you can't do this in Windows XP Home or in Vista Home Basic.

Also, users will be users: if you block local games, they'll play Flash browser games; if you block Flash, they'll play in-browser Javascript games; if you block that, they'll play pure-HTML text adventure games (while being rightfully pissed that you have incidentally blocked most other websites from functioning).

If you block even that, the users will abandon the computer and go smoking, or bring in cards and play Solitaire IRL, or find a myriad other ways to avoid work (assuming we're talking about office users) - so that's not a win either; unless you're trying to get the user(s) off the computer (as it looks from your comments).

Piskvor