|
ybfq
初级用户
 
积分 101
发帖 35
注册 2005-10-26
状态 离线
|
『楼 主』:
结:Win2000下批处理结束后禁止自动关闭窗口与choice无法运行
使用 LLM 解释/回答一下
1、在98下编一个20字节的批处理文件,在ms-dos窗口执行的好好的,可拿到2000上的cmd下一试,只见画面一闪而过,为什么留不住这个cmd窗口呢?在98的dos属性中有一个选项“退出时关闭”,在2000的cmd属性中为什么找不到?求问。
2、还有我的批文件中有choice这个命令,在98的ms-dos窗口中能运行,可在2000的cmd窗口中提示说不是内部命令(系统中根本没这个命令),那这样的屁文件还能在2000中运行吗?谢谢!
——————————————— Edited by willsort ———————————————
原标题:求教批处理文件的问题
为了方便广大用户的浏览和版主的管理
请楼主注意标题应该有对内容的概括性
——————————————— Edited by willsort ———————————————
Last edited by willsort on 2005-10-28 at 21:03 ]
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 ]
|
|
2005-10-26 16:24 |
|
|
无奈何
荣誉版主
      
积分 1338
发帖 356
注册 2005-7-15
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
1、批处理运行后自动退出,要显示窗口,在CMD下调用,或语句中加入 pause 暂停。
2、2000没有 choice.exe 可以用 set /p 替代,详情见 set /?。
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 /?.
|
|
2005-10-26 16:53 |
|
|
ybfq
初级用户
 
积分 101
发帖 35
注册 2005-10-26
状态 离线
|
『第 3 楼』:
求教退出批文件问题
使用 LLM 解释/回答一下
编一个批文件,在2000下双击后,该批文件执行后自动退出,但在98下,双击后,显示的dos执行画面执行完成后,dos窗口不能自动退出,请问:在批文件中加什么命令,才能在98下让我以双击批文件的方式下,完成执行后立即退出。谢谢!
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?
|
|
2005-10-28 09:47 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2005-10-28 10:11 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2005-10-28 10:12 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Re DOSforever:
这并不是一个很简单的问题,而且也还没有解决,所以暂时尚不用移动至(教学室)。因为楼主的系统环境是Win2000,而即使是在Win9x环境中,修改DOS窗口的属性不是仅作用于当前窗口,就是作用于全局窗口,无法就某个批处理的执行窗口进行设置,这个设置只有在批处理的快捷方式(PIF)属性中才能达成。而XP的PIF属性中没有了这个设置。
再对此问题略作引申以抛砖引玉。
首先,在大多数 XP 的环境中,点击执行完批处理后会自动关闭命令行窗口,对于某些程序就是一闪而过,而无法观察到程序的输出结果,在这种情况下,我们需要在程序完后暂停一下,等到用户确认后再退出,这时我的方案是,在程序的结束处加上一句暂停语句 pause 或者 pause>nul ,这样它会等待用户按任意键确认后再关闭窗口。
但是,我们已经知道,在某些 NT 系列环境中,点击执行完批处理后并不会自动关闭命令行窗口,除了批处理语句可能含有上文中提到的 pause 或者执行了其它带有暂停性质的语句之外,就是这个窗口总是不会默认关闭的,至于具体的原因,因为我无法接触到此类环境,所以无法确认。
不知道各位尤其楼主 ybfq 兄是否能够提供更详细的细节?
——————————————— Edited by willsort ———————————————
红色字体所示内容,经实际验证乃错误言论,敬请注意!
——————————————— Edited by willsort ———————————————
Last edited by willsort on 2005-10-28 at 19:57 ]
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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2005-10-28 13:27 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2005-10-28 13:34 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2005-10-28 14:08 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2005-10-28 14:11 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
Re DOSforever:
十分抱歉!不但匆忙之间没看清楼主的题意,而且同时发表了一些错误言论。上文中的第一段文字几乎毫无可取之处。
经过在 Win9x 下实际测试后证实,在批处理执行窗口的属性中,其“退出时关闭”默认是未选中的,如果勾选它,则会在自动在批处理所在路径下生成同名的快捷方式(PIF)文件。此后,每次退出此批处理均会自动关闭窗口。
而如果在 Command 的运行窗口属性中,其“退出时关闭”默认是选中的,如果取消勾选,则会影响 Windows 目录下的 command.pif 文件,而不会影响开始菜单中的 “MS-DOS 方式”,这个菜单实际上就是 MS-DOS 方式.pif 文件,位于 windows 的 Start Menu\Programs 目录下。以后,每次“运行” command 不会自动关闭窗口,而 “MS-DOS 方式” 仍然会自动关闭。
而如果一个批处理如果没有同名的 PIF 文件,则其 “退出时关闭” 必然未选中,如果有其他名字的指向此批处理的 PIF 文件的 “退出时关闭” 被选中,则只有执行此 PIF 才会自动关闭窗口,否则仍然不会自动关闭。
另外一种情况是,点击执行没有任何 PIF 文件的批处理,或者取消勾选 “退出时关闭” 的批处理,如果在程序执行的最后时刻没有屏幕输出,或者在程序的结束处加上 cls 或者 mode co80 等有清屏作用的语句,或者在程序执行过程中本就没有任何输出,则 Windows 仍将会自动关闭该批处理执行窗口。 exit 命令因为没有清屏作用,所以无效。
Last edited by willsort on 2005-10-30 at 10:53 ]
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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2005-10-28 16:34 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2005-10-28 17:16 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Re DOSforever:
特定类型文件的扩展名总被隐藏,与 NeverShowExt 这个键值有关系,找到对应类型下的同名键值,删除它即可。当然,还需要取消勾选 “隐藏已知文件类型的扩展名”,才可以显示扩展名。
我删除 lnkfile 文件的 NeverShowExt 后,终于发现,其实在 WinXP 的 PIF 中也有“退出时关闭”的选项,我那段陈述中的最后一句也是错误的!因为我是沿用 Win9x 下的经验,通过在批处理的右键菜单中选择“创建快捷方式”,来创建对应的 PIF 文件,结果在 WinXP 下,这样做的结果是产生了一个 LNK 文件,而我一直将它认作 PIF 文件,因为我看不到它的扩展名……
Last edited by willsort on 2005-10-28 at 19:56 ]
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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2005-10-28 19:46 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2005-10-28 20:24 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
Re DOSforever:
对应的文件类型可以从这个键值所在的“分支项”的名字中看出来,比如 lnkfile 下的 NeverShowExt 便对应的是 .LNK 文件类型。
这个值确实是空的,因为它是字符串类型,所以它的真假是靠存在与否来判定的。如果存在,则为真,则总是隐藏扩展名,反之亦然。
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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2005-10-28 20:35 |
|
|
dosz
中级用户
   一看二跟三动手
积分 396
发帖 188
注册 2005-10-23 来自 上海
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
在程序的结束处加上一句 goto exit
Last edited by dosz on 2005-10-30 at 10:21 ]
Add a line of `goto exit` at the end of the program
Last edited by dosz on 2005-10-30 at 10:21 ]
|
|
2005-10-29 23:32 |
|