Tech Support Guy banner
  • Please post in our Community Feedback thread for help with the new forum software! If you are having trouble logging in, please Contact Us for assistance.
Status
Not open for further replies.
1 - 18 of 18 Posts

·
Registered
Joined
·
1,307 Posts
Discussion Starter · #1 ·
Hey all,

I swear there was a way to create a batch file to shutdown applications such as AVG, MSN Messenger, etc. (obviously with one click) so that I can free up resources for gaming. I thought I saw it on Blackviper.com, but he's gone now. I've looked up MSDOS commands online, but couldn't find anything about how to do it.
Can anyone help?

Thanks,

Vince
 

·
Registered
Joined
·
671 Posts
I suppose you're not really talking about pure MSDOS, but the Command Shell in WinXP

In the XP command shell, you can use the TASKLIST and TASKKILL commands.
 

·
Registered
Joined
·
1,307 Posts
Discussion Starter · #3 ·
plejon said:
I suppose you're not really talking about pure MSDOS, but the Command Shell in WinXP

In the XP command shell, you can use the TASKLIST and TASKKILL commands.
Yes, I guess that was it. But do you know how to make it so that I can do a one-click and have several programs end?
 

·
Registered
Joined
·
671 Posts
First, run tasklist and write down the name of the task you want to stop. (eg notepad.exe)

Then, execute the following command: TASKKILL /F /IM notepad.exe
(See the list of all options for tasklist below)

To stop just one task, create a shortcut with the following properties:
Target: C:\WINDOWS\system32\taskkill.exe /F /IM notepad.exe
Start in: C:\WINDOWS\system32

If you want to stop several task, you can either add them to your command line C:\WINDOWS\system32\taskkill.exe /F /IM notepad.exe /IM mspaint.exe or create a batch file.

----------------------------------------------------
TASKKILL [/S system [/U username [/P [password]]]]
{ [/FI filter] [/PID processid | /IM imagename] } [/F] [/T]

Description:
This command line tool can be used to end one or more processes.
Processes can be killed by the process id or image name.

Parameter List:
/S system Specifies the remote system to connect to.

/U [domain\]user Specifies the user context under which
the command should execute.

/P [password] Specifies the password for the given
user context. Prompts for input if omitted.

/F Specifies to forcefully terminate
process(es).

/FI filter Displays a set of tasks that match a
given criteria specified by the filter.

/PID process id Specifies the PID of the process that
has to be terminated.

/IM image name Specifies the image name of the process
that has to be terminated. Wildcard '*'
can be used to specify all image names.

/T Tree kill: terminates the specified process
and any child processes which were started by it.

/? Displays this help/usage.

Filters:
Filter Name Valid Operators Valid Value(s)
----------- --------------- --------------
STATUS eq, ne RUNNING | NOT RESPONDING
IMAGENAME eq, ne Image name
PID eq, ne, gt, lt, ge, le PID value
SESSION eq, ne, gt, lt, ge, le Session number.
CPUTIME eq, ne, gt, lt, ge, le CPU time in the format
of hh:mm:ss.
hh - hours,
mm - minutes, ss - seconds
MEMUSAGE eq, ne, gt, lt, ge, le Memory usage in KB
USERNAME eq, ne User name in [domain\]user
format
MODULES eq, ne DLL name
SERVICES eq, ne Service name
WINDOWTITLE eq, ne Window title

NOTE: Wildcard '*' for the /IM switch is accepted only with filters.

NOTE: Termination of remote processes will always be done forcefully
irrespective of whether /F option is specified or not.

Examples:
TASKKILL /S system /F /IM notepad.exe /T
TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
TASKKILL /F /IM notepad.exe /IM mspaint.exe
TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"
 

·
Registered
Joined
·
1,307 Posts
Discussion Starter · #5 ·
plejon said:
First, run tasklist and write down the name of the task you want to stop. (eg notepad.exe)

Then, execute the following command: TASKKILL /F /IM notepad.exe
(See the list of all options for tasklist below)

To stop just one task, create a shortcut with the following properties:
Target: C:\WINDOWS\system32\taskkill.exe /F /IM notepad.exe
Start in: C:\WINDOWS\system32

If you want to stop several task, you can either add them to your command line C:\WINDOWS\system32\taskkill.exe /F /IM notepad.exe /IM mspaint.exe or create a batch file.
Yes, that's it, I want to create a batch file so I can have it on my desktop. I want to be able to stop several programs, so I can free up some resources for gaming, then start them after I'm done. Do I do that with the Command Shell? How do I make that batch file?
 

·
Registered
Joined
·
671 Posts
A batch file is a text file that contains several commands that you would normally type in the command shell.

To create a batch file, just open notepad, type the commands you want to execute, and save your file as SOMENAME.BAT. The .BAT is important, make sure notepad doesn't save your file as a .TXT

You can save the batch file anywhere you want on your harddisk, just make sure you know where to find it later.

That's your batch file, if you want a convenient way to execute it, create a shortcut on your desktop that point to the batch file.
 

·
Registered
Joined
·
1,307 Posts
Discussion Starter · #8 ·
Okay, I guess I'm doing something wrong.

I opened Notepad, and typed this:
TASKKILL /F /IM avgcc.exe /IM avgemc.exe /IM avgupsvc.exe /IM msnmsgr.exe

I also tried it this way too:
TASKKILL /F /IM avgcc.exe
TASKKILL /F /IM avgemc.exe
TASKKILL /F /IM avgupsvc.exe
TASKKILL /F /IM msnmsgr.exe

Saved it as a ".bat" file

Then I double clicked on it. It opened and closed really quick, as if it worked, but when I checked my tasklist, the items were still open.

What am I doing wrong? And is there a way to make one to start those programs when I want (after I'm done gaming), so I don't have to reboot?

Thanks again for your help
 

·
Registered
Joined
·
671 Posts
As you indicate, the trouble when debugging batch files is that the window opens and closes very quick, so you don't see a thing. A good trick to avoid this problem is to put an PAUSE command at the end of your batch file. (Or even somewhere in the middle of the batch file as appropriate). This will cause a "Press any key..." message to appear so you have ample time to read any error messages and find out what's going wrong.

So, try this as your batch file:
TASKKILL /F /IM avgcc.exe
TASKKILL /F /IM avgemc.exe
TASKKILL /F /IM avgupsvc.exe
TASKKILL /F /IM msnmsgr.exe
PAUSE

Starting the programs back up later is even easier. Just create a second batch file with the names of the exe's. If the exe's are not in your path, you will need to type the entire file name including the path:

If the AVG exe's are in c:\program files\avg , the batch file should look someting like this:
C:\program files\avg\avgcc.exe
C:\program files\avg\avgemc.exe
C:\program files\avg\avgupsvc.exe
C:\program files\MSN messenger\msnmsgr.exe
PAUSE

You might need to append startup parameters to the program names as appropriate.
 

·
Retired Trusted Advisor
Joined
·
19,786 Posts
DoubleHelix said:
Are you running Windows XP Home or Pro? TASKKILL is not included with Home.
Wow, I did not know that. Well there is a substitute for everything. You can download PSKILL from Sysinternals. I recommend downloading the entire PSTOOLS set because alot of them come in handy. But you can just download the individual tools.

http://www.sysinternals.com/Utilities/PsTools.html
 

·
Retired Trusted Advisor
Joined
·
19,786 Posts
Did a little more searching on the net. There is a utility on XP Home and Pro called TSKILL that has similar functionality. But alot of people have posted TASKKILL for download if you really want to use that.
 
1 - 18 of 18 Posts
Status
Not open for further replies.
Top