中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-02 04:41
48,037 topics / 350,122 posts / today 2 new / 48,250 members
DOS批处理 & 脚本技术(批处理室) » How to tell in a batch file whether a certain program has already been loaded?
Printable Version  1,407 / 8
Floor1 Lydong Posted 2002-11-30 00:00
元老会员 Posts 407 Credits 1,468 From 广州
In a batch file, sometimes you want to determine whether a TSR has already been run, so as to execute the corresponding program. What I want to ask is: is there any way to let a batch file detect this automatically?
Floor2 MYS Posted 2002-12-01 00:00
元老会员 Posts 1,637 Credits 5,170 From 广东佛山
Unless you set an environment variable when starting it, it is impossible for a batch file itself to detect whether a program has already been loaded.
For example, add a line after UCDOS.BAT: “set ucdos=onload"
And if you write a batch file to exit UCDOS, also add "SET UCDOS=" after it
That way, in the batch file you can use IF UCDOS =="onload" to determine whether UCDOS has been loaded.
Floor3 Wengier Posted 2002-12-01 00:00
系统支持 Posts 10,521 Credits 27,736
You can use some specialized tools, such as TSR Utils, to determine whether a specified program has already been loaded.
Floor4 Lydong Posted 2002-12-01 00:00
元老会员 Posts 407 Credits 1,468 From 广州
I downloaded TSR Utils, but I don't know how to use it. Wengier, could you introduce it a bit? Thanks!
Floor5 Wengier Posted 2002-12-01 00:00
系统支持 Posts 10,521 Credits 27,736
For example: MAPMEM /C COMMAND can determine whether COMMAND is loaded. If you also want to include UMB, add the /U option, that is, MAPMEM /U /C COMMAND. It can not only directly display on the screen whether this program has already been loaded, it will also automatically set the ERRORLEVEL value: if it is loaded, it is 0; if not loaded, it is 2; if there is a syntax error, it is 1.
Floor6 Lydong Posted 2002-12-01 00:00
元老会员 Posts 407 Credits 1,468 From 广州
Why does it stop moving as soon as I enter it (it seems to hang)? I don't know whether there is a problem with the software.
The prompt is as follows:
c:\tsrcom35>mapmem /c command
MAPMEM 3.5, Copyright 1993 TurboPower Software
_
Floor7 Wengier Posted 2002-12-02 00:00
系统支持 Posts 10,521 Credits 27,736
No way! Could it be that your system was unstable at the time?
Floor8 jmcarl Posted 2003-03-18 00:00
中级用户 Posts 73 Credits 355
Try this! Open attachment
Floor9 mobo Posted 2006-09-24 09:13
初级用户 Posts 30 Credits 73
::Check whether there is a specified running program in the process list, such as 'explorer.exe'
::------------BY MOBO[墨伯]
::-------------2006-09-22
wmic process where name='explorer.exe' get caption>out.txt

We should still make more use of WMIC. A stone from another mountain may polish jade; it provides a large number of interfaces for reading software and hardware [about 6000 properties], and also some methods, all of them quite useful.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023