Can a batch file be written to shut down unused processes in task manager?

Stinkfinger

Senior member
Apr 12, 2005
230
0
0
I can't run BF2 on my pretty much state of the art pc. EA suggests shutting down all processes except taskmgr.exe, explorer.exe and any under system, local service, and network service.

Can I write a batch file to shut down all processes except those mentioned above? Better yet, is there a program that will do it?
 

skace

Lifer
Jan 23, 2001
14,488
7
81
Originally posted by: nweaver
you could use pskill and batch file it

pskill and pslist

for /f "tokens=1,2" %%i in ('pslist') do call :start "%%i" "%%j"
goto :eof

:start
if "%~1"=="explorer" goto :eof
if "%~1"=="taskmgr" goto :eof
pskill %~2
goto :eof

Granted, this is a very sloppy example, you get the idea. I'd be pretty sure the end result is you would kill something necessary. The only way to avoid this is to boot up fresh and close everything you think shouldn't be running and then take down the 8-10 necessary processes and write the script around them. I also wouldn't kill any svchost processes either...
 

statik213

Golden Member
Oct 31, 2004
1,654
0
0
Also, if you know the names of the processes you want to kill you can simply do this:

tskill proc1
tskill proc2
...
tskill procn
 

Stinkfinger

Senior member
Apr 12, 2005
230
0
0
Am I missing something here? All of these ideas here seem like a long work around for what task manager can do with a couple clicks.
 

statik213

Golden Member
Oct 31, 2004
1,654
0
0
Originally posted by: Stinkfinger
Am I missing something here? All of these ideas here seem like a long work around for what task manager can do with a couple clicks.


Ahem, he want to avoid the clicking part... and kill multiple programs in one go.
 

statik213

Golden Member
Oct 31, 2004
1,654
0
0
d'oh! didn't see that you were the OP...

do: tskill * -- it kills all your running programs. It sometimes triggers a shutdown (in 60 secs). Then hit ctrl+shift+esc (or ctrl+alt+del) real quick to get the task manager, click on new task (I think) type cmd, to get a command prompt. Do `shutdown -a` -- that should kill the shutdown process. type explorer to get the desktop back and you should have very few programs running.
Try BF2 then.
 

skace

Lifer
Jan 23, 2001
14,488
7
81
Originally posted by: Stinkfinger
Am I missing something here? All of these ideas here seem like a long work around for what task manager can do with a couple clicks.

I wrote a simple batch file, once setup would allow you to simply click and shutdown the specified tasks. How is double clicking on a .bat file a long work around?
 

Stinkfinger

Senior member
Apr 12, 2005
230
0
0
When I go here to learn the syntax of using the tskill, do I need to enter what's after the braces if the processes are on my local machine?

Also, is tskill installed with XP or do I need to go download it.
 

skace

Lifer
Jan 23, 2001
14,488
7
81
Based on that website, parameters in {}'s are needed, the "|" means either/or and []'s mean not necessary. Syntax help also uses <>'s to define necessary parameters, and you may see this elsewhere.

In other words, you will always need either a Process ID OR a Process Name. The /server, /id, /a, and /v are all optional parameters. In the /id case, It is necessary that you either use /id OR /a and never both, but using either is completely optional.
 

skace

Lifer
Jan 23, 2001
14,488
7
81
It looks like tskill and tlist are both available in windows xp pro. I've been using the ps utils since the NT days so I don't always know what is available. Just type the commands into a dos window to see if you have them.

 

skace

Lifer
Jan 23, 2001
14,488
7
81
This uses tlist/tskill and echoes everything it does instead of actually doing it right now. I named it temp.bat with a temp.lst, temp.lst is simply a text file with a line for every needed process

ie (this isn't all of them):
svchost.exe
ntaskldr.exe
explorer.exe
ntmulti.exe
spoolsv.exe
winlogon.exe
services.exe
taskmgr.exe
 

Stinkfinger

Senior member
Apr 12, 2005
230
0
0
So if I create a .bat from the code you provided, everything will shut down except what's listed above the code in your previous post? If that's the case, thank you very much!
 

skace

Lifer
Jan 23, 2001
14,488
7
81
Well yes, just make sure you have setup a temp.lst in the same directory as the .bat file with the processes you don't want stopped. Then run it and it should tell you everything it would close and what it wouldn't close. If that looks right, then just unecho the tskill command and resave the bat file.
 

21stHermit

Senior member
Dec 16, 2003
927
1
81
Originally posted by: Stinkfinger
So if I create a .bat from the code you provided, everything will shut down except what's listed above the code in your previous post? If that's the case, thank you very much!
Could you post an example of the bat file that worked for you? I'm trying to do the same thing, as yet I do not understand the syntax. When I typed tskill name.exe into the command prompt, it said it could not find the process.

Thanks,
Hermit
 

sandorski

No Lifer
Oct 10, 1999
70,677
6,250
126
IMO, you're wasting your time shutting all these Proceses down. Unless you barely have enough to meet the bare minimum requirements for the game.