China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-01 09:03
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » How to close all windows View 1,553 Replies 6
Original Poster Posted 2007-04-28 05:04 ·  中国 内蒙古 包头 联通
初级用户
我很想学DOS
Credits 30
Posts 12
Joined 2007-04-28 04:32
19-year member
UID 86736
Gender Male
Status Offline
In the Windows XP system, users often open many windows simultaneously, such as frequently opening a dozen web pages and programs, which causes system resource strain and slow running speed. I want to use cmd to make a batch script to forcibly close all open windows and programs, but not to shut down or log off. Please teach me how to do it.

[ Last edited by bgwzlgf9610 on 2007-4-27 at 04:36 PM ]
Floor 2 Posted 2007-04-28 06:42 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
You can first write a process list into a file, for example, store the processes to be closed in it, and then use a batch script to read the contents of this file to close the relevant processes to achieve the purpose. This file can also store the list of processes that are not to be closed.
Floor 3 Posted 2007-04-28 23:25 ·  中国 内蒙古 包头 联通
初级用户
我很想学DOS
Credits 30
Posts 12
Joined 2007-04-28 04:32
19-year member
UID 86736
Gender Male
Status Offline
Thanks, moderator lxmxn.
What I'm talking about here is the randomly opened web pages, games, and program windows by students. Then how to distinguish the content of the process list I get, so as not to close the system processes but only close the content I want to close?
Floor 4 Posted 2007-04-29 02:48 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Re bgwzlgf9610:

You can write several main processes of the system in 1.txt, one per line, and then write a batch script to end processes that are not in this file, so that you can close the processes you want to close.

The content in 1.txt is actually the list of processes you don't want to close.
Floor 5 Posted 2007-04-29 03:56 ·  中国 内蒙古 包头 联通
初级用户
我很想学DOS
Credits 30
Posts 12
Joined 2007-04-28 04:32
19-year member
UID 86736
Gender Male
Status Offline
The ideas of the moderator are very inspiring, thank you first.
But I have tried for a long time without substantial progress. I wonder if the moderator can be so kind as to give a specific example.
For example: There are three processes, explorer, csrss and xiandan.exe. I want to end xiandan.exe while keeping explorer and csrss.
Can it be written like this in 1.txt:
explorer
csrss
.
The key is how to do it with a batch script. I don't know how. I have tried for a long time and haven't completed it. I have searched for a long time on the forum and haven't found the content I want.
Floor 6 Posted 2007-04-29 04:11 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Re bgwzlgf9610:

Your 1.txt can write the processes to end, for example:
xiandan.exe
qq.exe

Then use this:

@echo off
for /f "tokens=" %%a in (1.txt) do taskkill /f /im %%a 2>nul
Floor 7 Posted 2007-04-29 04:23 ·  中国 内蒙古 包头 联通
初级用户
我很想学DOS
Credits 30
Posts 12
Joined 2007-04-28 04:32
19-year member
UID 86736
Gender Male
Status Offline
Thanks to lxmxn for his enthusiastic help and hard work.
I have already known how to solve similar problems.
Forum Jump: