中国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-26 01:14
47,812 topics / 349,910 posts / today 0 new / 48,264 members
其它操作系统综合讨论区 » Conclusion: The automatic closing of the window is prohibited after the batch processing ends under Win2000 and the choice cannot run
Printable Version  4,245 / 16
Floor1 ybfq Posted 2005-10-26 16:24
初级用户 Posts 35 Credits 101
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 ]
Floor2 无奈何 Posted 2005-10-26 16:53
荣誉版主 Posts 356 Credits 1,338
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 /?.
Floor3 ybfq Posted 2005-10-28 09:47
初级用户 Posts 35 Credits 101
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?
Floor4 DOSforever Posted 2005-10-28 10:11
金牌会员 Posts 2,239 Credits 4,639
In the properties of this DOS window, check the "Close on exit" option.
Floor5 DOSforever Posted 2005-10-28 10:12
金牌会员 Posts 2,239 Credits 4,639
Additionally, it is suggested to transfer this post to the (Classroom) and delete my reply.
Floor6 willsort Posted 2005-10-28 13:27
元老会员 Posts 1,512 Credits 4,432
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 ]
Floor7 DOSforever Posted 2005-10-28 13:34
金牌会员 Posts 2,239 Credits 4,639
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.
Floor8 不得不爱 Posted 2005-10-28 14:08
超级版主 Posts 2,044 Credits 5,310 From 四川南充
Just add a line of EXIT at the end of the batch file!
Floor9 DOSforever Posted 2005-10-28 14:11
金牌会员 Posts 2,239 Credits 4,639
If you don't select that option, just EXIT, the window won't close either
Floor10 willsort Posted 2005-10-28 16:34
元老会员 Posts 1,512 Credits 4,432
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 ]
Floor11 DOSforever Posted 2005-10-28 17:16
金牌会员 Posts 2,239 Credits 4,639
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?
Floor12 willsort Posted 2005-10-28 19:46
元老会员 Posts 1,512 Credits 4,432
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 ]
Floor13 DOSforever Posted 2005-10-28 20:24
金牌会员 Posts 2,239 Credits 4,639
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?
Floor14 willsort Posted 2005-10-28 20:35
元老会员 Posts 1,512 Credits 4,432
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.
Floor15 dosz Posted 2005-10-29 23:32
中级用户 Posts 188 Credits 396 From 上海
Add a line of `goto exit` at the end of the program

[ Last edited by dosz on 2005-10-30 at 10:21 ]
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023