473,378 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Process Kill?

58
How would you make a program that kills a system process?
Mar 18 '07 #1
12 6748
bartonc
6,596 Expert 4TB
How would you make a program that kills a system process?
Do you know how to do what you want from the command line? If so, please supply an example. If not, you'll need this info first.
Mar 18 '07 #2
shing
58
i want to be able to process kill explorer.exe (not to be confused with iexplore)

This will allow me to see my background and have any amount of programs on my computer without them being in front of my background { its a secret ;) }

Please help me, Bartonc
Mar 18 '07 #3
ghostdog74
511 Expert 256MB
if you know the pid, you can use kill(), check this os process management
Mar 18 '07 #4
bartonc
6,596 Expert 4TB
i want to be able to process kill explorer.exe (not to be confused with iexplore)

This will allow me to see my background and have any amount of programs on my computer without them being in front of my background { its a secret ;) }

Please help me, Bartonc
I don't recommend what you are talking about. Explorer is listed as "important for the stable running of you operating system". That said:
Expand|Select|Wrap|Line Numbers
  1. import os
  2. os.system("taskkill  /im explorer.exe")
might just do it.

system( command)

Execute the command (a string) in a subshell. This is implemented by calling the Standard C function system(), and has the same limitations. Changes to posix.environ, sys.stdin, etc. are not reflected in the environment of the executed command.

On Windows, the return value is that returned by the system shell after running command, given by the Windows environment variable COMSPEC: on command.com systems (Windows 95, 98 and ME) this is always 0; on cmd.exe systems (Windows NT, 2000 and XP) this is the exit status of the command run; on systems using a non-native shell, consult your shell documentation.
Mar 18 '07 #5
shing
58
Can your posts please be put into more comphrensible terms? I'm only 16...

Not to mention I just started Python...
Mar 18 '07 #6
bartonc
6,596 Expert 4TB
Can your posts please be put into more comphrensible terms? I'm only 16...

Not to mention I just started Python...
I ran a test. This works to kill a process that you know the name of (in this case "notepad.exe").

>>> import os
>>> os.system("taskkill /im notepad.exe")
0
>>>
os is a standard library module. You can look it up in Start->Programs->Python 2.x-> Python Manuals. Click on the Global Module Index link. Scroll down to os and hit that link. You need to be able to find stuff in the manual and understand what is in there. That way when you see and example, you can look up the part that you don't understand.
Mar 18 '07 #7
shing
58
1. Why does it return a "0"? I tried it on other programs, and, when it fails it returns a "128".

2. What does "/im" do?
Mar 18 '07 #8
bartonc
6,596 Expert 4TB
1. Why does it return a "0"? I tried it on other programs, and, when it fails it returns a "128".
0 means "no error"
2. What does "/im" do?
Start->Help and Support: Search taskkill:

TaskkillEnds one or more tasks or processes. Processes can be killed by process ID or image name.

Syntax
taskkill [/s Computer] [/u Domain\User [/p Password]]] [/fi FilterName] [/pid ProcessID]|[/im ImageName] [/f][/t]

Parameters
/s Computer
Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer.
/u Domain\User
Runs the command with the account permissions of the user specified by User or Domain\User. The default is the permissions of the current logged on user on the computer issuing the command.
/p Password
Specifies the password of the user account that is specified in the /u parameter.
/fi FilterName
Specifies the types of process(es) to include in or exclude from termination. The following are valid filter names, operators, and values.
Mar 18 '07 #9
shing
58
i dont understand how "IM" stands for TASK KILL....shouldnt it be TK?wait hang on...i saw a line....so um...IM stands for imageName? how strange....anyways.....does imagename just mean the filename?
Mar 19 '07 #10
shing
58
Now look at this:

AVAILABILITY
The taskkill command is an external command that is available in the below Microsoft Operating Systems.

Windows XP Professional


what if my computer is NOT a windows XP Professional? >_>

taken from this URL: http://www.computerhope.com/taskkill.htm
Mar 19 '07 #11
bartonc
6,596 Expert 4TB
i dont understand how "IM" stands for TASK KILL....shouldnt it be TK?wait hang on...i saw a line....so um...IM stands for imageName? how strange....anyways.....does imagename just mean the filename?
os.system() calls spawns cmd.exe and pass the string "taskkill /im whatever.exe" to it. Taskkill is a Windows command (it's just an arbitrary string in python - where'd you get TK, anyway?). The "/im" tells killtask that you know the IMage name of the process that you want to kill (as oposed to /pid, when you know the process ID). I hope that's clear enough. All this is in the docurmtation that I have provided.
Mar 19 '07 #12
bartonc
6,596 Expert 4TB
Now look at this:

AVAILABILITY
The taskkill command is an external command that is available in the below Microsoft Operating Systems.

Windows XP Professional


what if my computer is NOT a windows XP Professional? >_>

taken from this URL: http://www.computerhope.com/taskkill.htm
Then look up the "command line reference a to z" for your computer. Sorry about that (I hate using command line commands and didn't consider that some might not be on all machines).
Mar 19 '07 #13

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

Similar topics

21
by: John Lin | last post by:
Howdy, I want to know how to tell if a forked process is done. Actually, my real question is that I want to run a shell script inside of a python script, and after the shell script has...
3
by: pattanawadee | last post by:
Deall All, Could anybody suggestion me How to kill all inherrit processes (sibling child,previous and parent process) in the case I know only child process id and user id, For example I strart...
1
by: Mullin Yu | last post by:
But, I want is that I can have a Main app that will start a new process or kill one particular or all process. The process will open a console exe. But, I don't want the user to close the console...
2
by: Hayato Iriumi | last post by:
Hello, I have a need to kill a process. It sounds each enough, but the problem is that I have multiple executables running from different paths. Say, I have MyService.exe running from C:\FolderA...
6
by: gizmo | last post by:
I have a requirement to initiate more than one instance of an application using the filenames. (the example below will start two instances of MS Word). My problem is that I need to kill each...
0
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a...
5
by: Dino Buljubasic | last post by:
My application can allow a user to open a file for viewing by fetching file data from database, creating the file in a temp directory and starting appropriate process (i.e. Adobe or any other...
8
by: Rain | last post by:
Does anyone know how i can kill a process using C#? im developing an asp.net web application using C# and the asp.net process doesnt die even if the application has already exited. So i need to...
9
by: SeC | last post by:
Hi. Is there any way to detect if application is being killed by 'End Process' via Task Manager ?
4
by: Richard Rossel | last post by:
Hi Fellows, I have a problem with process termination. I have a python code that apache runs through a django interface. The code is very simple, first, it creates a process with the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.