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-06-30 03:44
中国DOS联盟论坛 » 其它操作系统综合讨论区 » Conclusion: The automatic closing of the window is prohibited after the batch processing ends under Win2000 and the choice cannot run View 3,980 Replies 16
Original Poster Posted 2005-10-26 16:24 ·  中国 浙江 绍兴 诸暨市 电信
初级用户
Credits 101
Posts 35
Joined 2005-10-26 16:18
20-year member
UID 44101
Status Offline
1、Under Windows 98, a 20-byte batch file is compiled. When executed in the MS-DOS window, it runs well. But when tried in the cmd of Windows 2000, the screen flashes and disappears. Why can't the cmd window be kept? In the DOS properties of Windows 98, there is an option "Close on exit", but why can't this option be found in the cmd properties of Windows 2000? Please ask.

2、Also, there is the choice command in my batch file. In the MS-DOS window of Windows 98, it can run, but in the cmd window of Windows 2000, it prompts that it is not an internal command (the system doesn't have this command at all). Then can such a fart file still run in Windows 2000? Thanks!


——————————————— Edited by willsort ———————————————
Original title: Ask for help on batch file issues
For the convenience of users' browsing and moderators' management
Please note that the title should have a summarizing nature of the content
——————————————— Edited by willsort ———————————————


[ Last edited by willsort on 2005-10-28 at 21:03 ]
Floor 2 Posted 2005-10-26 16:53 ·  中国 辽宁 锦州 中移铁通
荣誉版主
★★★
Credits 1,338
Posts 356
Joined 2005-07-15 12:09
20-year member
UID 40733
Gender Male
Status Offline
1. After the batch processing runs and exits automatically, to display the window, call it in CMD, or add the pause statement in the statement to pause.
2. There is no choice.exe in 2000, you can use set /p instead, for details, see set /?.
Floor 3 Posted 2005-10-28 09:47 ·  中国 浙江 绍兴 诸暨市 电信
初级用户
Credits 101
Posts 35
Joined 2005-10-26 16:18
20-year member
UID 44101
Status Offline
Write a batch file that, when double-clicked under Windows 2000, executes and then automatically exits. But under Windows 98, after the DOS execution screen finishes, the DOS window doesn't automatically exit. What command should be added in the batch file so that under 98, when double-clicked, the batch file finishes executing and then immediately exits?
Floor 4 Posted 2005-10-28 10:11 ·  中国 上海 黄浦区 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
In the properties of this DOS window, check the "Close on exit" option.
Floor 5 Posted 2005-10-28 10:12 ·  中国 上海 黄浦区 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
Additionally, it is suggested to transfer this post to the (Classroom) and delete my reply.
Floor 6 Posted 2005-10-28 13:27 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re DOSforever:

This is not a very simple problem, and it hasn't been solved yet, so it's not necessary to move it to (Classroom) for the time being. Because the owner's system environment is Win2000, and even in the Win9x environment, modifying the properties of the DOS window either only affects the current window or the global window, and it's impossible to set it for the execution window of a certain batch file. This setting can only be achieved in the shortcut (PIF) properties of the batch file. And this setting is no longer available in the PIF properties of XP.

Let's expand a bit on this issue to inspire further discussion.

First of all, in most XP environments, the command line window will automatically close after executing the batch file. For some programs, it just flashes by and the output result of the program cannot be observed. In this case, we need to pause the program for a while and wait until the user confirms before exiting. At this time, my solution is to add a pause statement pause or pause>nul at the end of the program, so that it will wait for the user to press any key to confirm before closing the window.

However, we have known that in some NT series environments, the command line window will not automatically close after executing the batch file. Except that the batch file statement may contain the pause mentioned above or execute other statements with a pause nature, the window always does not close by default. As for the specific reason, because I can't access such an environment, I can't confirm.

I don't know if you, especially the owner Brother ybfq, can provide more detailed details?


——————————————— Edited by willsort ———————————————
The content shown in red font has been verified to be incorrect remarks, please pay attention!
——————————————— Edited by willsort ———————————————


[ Last edited by willsort on 2005-10-28 at 19:57 ]
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 7 Posted 2005-10-28 13:34 ·  中国 上海 黄浦区 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
Hehe, please let "Xiaotian" read the original poster's post again carefully and see his requirements. However, I really haven't run batch under Win NT/2000/XP, and I don't know the phenomenon you mentioned.
Floor 8 Posted 2005-10-28 14:08 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 9 Posted 2005-10-28 14:11 ·  中国 上海 黄浦区 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
If you don't select that option, just EXIT, the window won't close either
Floor 10 Posted 2005-10-28 16:34 ·  中国 山西 太原 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re DOSforever:

I'm extremely sorry! Not only did I fail to understand the original poster's intention in a hurry, but I also made some incorrect remarks at the same time. The first paragraph in the above text is almost of no value.

After actual testing under Win9x, it has been confirmed that in the properties of the batch processing execution window, the "Close on exit" is not selected by default. If you check it, a shortcut (PIF) file with the same name will be automatically generated in the path where the batch processing is located. From then on, each time this batch processing is exited, the window will be automatically closed.

And in the properties of the Command running window, "Close on exit" is selected by default. If you uncheck it, it will affect the command.pif file in the Windows directory, but will not affect the "MS-DOS mode" in the Start Menu. This menu is actually the MS-DOS mode.pif file, located in the windows\Start Menu\Programs directory. From then on, each time "Run" command is executed, the window will not be automatically closed, while the "MS-DOS mode" will still be automatically closed.

And if a batch processing has no PIF file with the same name, then its "Close on exit" must be unselected. If the "Close on exit" of other PIF files pointing to this batch processing is selected, then only when this PIF is executed will the window be automatically closed; otherwise, it will still not be automatically closed.

Another situation is that when you click to execute a batch processing without any PIF file, or a batch processing with "Close on exit" unselected. If there is no screen output at the final moment of program execution, or if statements with screen clearing effects such as cls or mode co80 are added at the end of the program, or if there is no output during the program execution, then Windows will still automatically close the batch processing execution window. The exit command is ineffective because it has no screen clearing effect.

[ Last edited by willsort on 2005-10-30 at 10:53 ]
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 11 Posted 2005-10-28 17:16 ·  中国 上海 黄浦区 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
Hehe, "Xiaotian" is being modest. Your passage is not completely without merit, just misapplied. If it weren't for your passage, I wouldn't have known about this feature of running batch under Win NT/2000/XP.

Speaking of this issue, it just reminds me of another problem. That is, in "Folder Options" -> "View", even if "Hide extensions for known file types" is not checked, some files still don't display their extensions, such as.pif.lnk. Does anyone know how to make all files display their extensions?
Floor 12 Posted 2005-10-28 19:46 ·  中国 山西 大同 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re: DOSforever:

The extension of specific types of files is always hidden, which is related to the key value "NeverShowExt". Find the corresponding key value under the same type and delete it. Of course, you also need to uncheck "Hide extensions for known file types" to display the extensions.

After I deleted the "NeverShowExt" of the lnkfile file, I finally found that there is also an "Close on Exit" option in the PIF of WinXP. The last sentence in my statement is also wrong! Because I used the experience under Win9x, by selecting "Create Shortcut" in the right-click menu of the batch processing, to create the corresponding PIF file. As a result, under WinXP, the result of doing this is to generate a LNK file, and I have been recognizing it as a PIF file all the time because I can't see its extension...

[ Last edited by willsort on 2005-10-28 at 19:56 ]
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 13 Posted 2005-10-28 20:24 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
I found quite a few such key values in the registry, but the problem is that I can't see which extension it corresponds to, and it's strange that the data of its key value is empty, that is, even if this key value exists, it's invalid?
Floor 14 Posted 2005-10-28 20:35 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re DOSforever:

The corresponding file type can be seen from the name of the "branch item" where this key value is located. For example, NeverShowExt under lnkfile corresponds to the .LNK file type.

This value is indeed empty because it is of string type, so its truth value is determined by existence. If it exists, it is true, and the extension is always hidden; otherwise, it is the opposite.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 15 Posted 2005-10-29 23:32 ·  中国 上海 浦东新区 电信
中级用户
★★
一看二跟三动手
Credits 396
Posts 188
Joined 2005-10-23 13:21
20-year member
UID 43919
From 上海
Status Offline
Add a line of `goto exit` at the end of the program

[ Last edited by dosz on 2005-10-30 at 10:21 ]
Forum Jump: