|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『楼 主』:
[讨论]explorer进程的特殊性
使用 LLM 解释/回答一下
To All:
前日,完成一个对文件夹进行处理的批处理代码。其中有一段代码意图使用资源浏览器打开操作后的文件夹,待用户确认无误关闭该文件夹的浏览器窗口后,执行后续的处理操作。代码如下:
但结果发现,start /w “并未起到其应有的作用”,也就是说,在打开test文件夹之后,未等待其关闭,就已经输出Program is finished.和return errorlevel: 0了,其它后续操作也被依次执行,直至该文件夹被删除后,浏览器窗口被自动关闭。
当然,在这里我不主张去怀疑 start/w 是否存在什么Bug,而是去思考资源浏览器的explorer进程是否有什么特殊性,使其影响了 start/w 的表现。
md test
:: other codes
start /w test & echo Program is finished.
:: return errorlevel: 0
::start /w explorer test & echo Is finished.
:: return errorlevel: 1
echo return errorlevel: %errorlevel%
:: other codes
Last edited by willsort on 2006-6-20 at 11:17 ]
To All:
The other day, I completed a batch processing code for processing a folder. There is a segment of code that intends to use the resource explorer to open the processed folder. After the user confirms that it is correct and closes the browser window of the folder, the subsequent processing operations are executed. The code is as follows:
But the result is that start /w "did not play its due role", that is, after opening the test folder, it did not wait for it to close, and then output Program is finished. and return errorlevel: 0, and other subsequent operations are also executed in turn until the folder is deleted, and the browser window is automatically closed.
Of course, here I don't advocate doubting whether there is any bug in start/w, but to think about whether there is any particularity of the explorer process of the resource explorer, which affects the performance of start/w.
md test
:: other codes
start /w test & echo Program is finished.
:: return errorlevel: 0
::start /w explorer test & echo Is finished.
:: return errorlevel: 1
echo return errorlevel: %errorlevel%
:: other codes
Last edited by willsort on 2006-6-20 at 11:17 ]
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2006-6-20 10:25 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
执行的应用程序是 32-位 GUI 应用程序时,CMD.EXE 不等应用
程序终止就返回命令提示。如果在命令脚本内执行,该新行为
则不会发生。
以上是START命令帮助中写到的.............
When executing a 32-bit GUI application, CMD.EXE returns to the command prompt before the application terminates. However, this new behavior does not occur when executing within a command script.
The above is written in the HELP for the START command.............
|
|
2006-6-20 10:40 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
噢,SORRY,wil说的是,我刚才没有试验其他程序,确实,其他程序是等待其窗口才继续执行,EXPLORER.EXE确不是,有待考虑........
Oh, SORRY, wil said that I didn't test other programs just now. Indeed, other programs wait for their windows to continue execution, but EXPLORER.EXE is not like that, which needs to be considered........
|
|
2006-6-20 10:44 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
本人觉得EXPLORER打开目录的动作,只要打开了就结束进程从而继续执行程序的,而其他程序例如执行SOL.EXE纸牌程序,用START执行的时候是挂起状态所以不会继续执行,EXPLORER只是一个执行动作,而这个动作结束后就会继续执行脚本以下的命令,打开TEST目录则是最终结果。
I think that the action of opening a directory with EXPLORER is such that once it's opened, the process ends and the program continues to execute. While for other programs like executing the SOL.EXE solitaire program, when started with START, it's in a suspended state and thus doesn't continue to execute. EXPLORER is just an execution action, and after this action ends, it will continue to execute the commands following the script. Opening the TEST directory is the final result.
|
|
2006-6-20 10:48 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Re bagpipe(2楼):
这个信息似乎不能说明什么。
一者,我确是在命令脚本中执行的,但该行为仍然发生了;
二者,对于同样是 32-位 GUI 应用程序的notepad和calc之流,他们仍然受着start/w的影响,无论在命令行还是在批处理;
三者,即使在脚本中,未使用/w调用notepad或者calc,也仍然是未等关闭便返回了;只是,是否返回命令提示,那要看脚本是否在命令行中运行,以及是否完成运行。
Re bagpipe(4楼):
兄提到了“挂起”,这让我想起,explorer作为Windows的外壳通常是不应被挂起的,否则桌面操作将无法保证。
但是,我们的start test并未开启新的explorer进程,而只是在explorer进程内增加了一个test线程,这与新建进程的32位程序和不新建进程和线程的内部命令都不太相同。
所以,我们的立足点仍是要寻找explorer有什么特殊性,尤其是在进程或线程状态上有什么特殊性。
Last edited by willsort on 2006-6-20 at 11:01 ]
Re bagpipe (Post 2):
This information doesn't seem to explain anything.
First, I did execute it in the command script, but this behavior still occurred;
Second, for 32-bit GUI applications like notepad and calc, they are still affected by start/w, whether in the command line or in batch processing;
Third, even in the script, if notepad or calc is not called with /w, it still returns before closing; however, whether the command prompt is returned depends on whether the script is run in the command line and whether it has completed running.
Re bagpipe (Post 4):
Brother mentioned "suspension", which reminds me that explorer, as the Windows shell, should generally not be suspended, otherwise desktop operations cannot be guaranteed.
But our start test does not start a new explorer process, but only adds a test thread within the explorer process, which is quite different from 32-bit programs that create new processes and internal commands that do not create new processes and threads.
So our starting point is still to find what is special about explorer, especially in terms of process or thread states.
Last edited by willsort on 2006-6-20 at 11:01 ]
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2006-6-20 10:51 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
请大家小心,Willsort编了一段病毒代码
情况是这样的:当我把这段代码copy下来之后,放到单独的批处理中运行之后,立马弹出了上百个CMD窗口,不断提示"子目录或者文件 test 已经存在",搞得我手忙脚乱,好不容易终止了CMD进程,后来在每句执行语句后加上了一个pause来单步执行,截取到的屏幕如下所示。
后来发现,无论start是否起用参数 /w ,都会出现这个问题,而去掉start /w之后,则不会打开test,而用explorer test语句,则可以顺利打开。
既然是这样,是否可以这样推断:在CMD的默认设置中,文件夹和资源管理器并没有关联起来,所以要指定文件夹的打开方式?
Please be careful, Willsort has compiled a piece of virus code: P
The situation is like this: After I copied this code down and put it in a separate batch file to run, hundreds of CMD windows popped up immediately, continuously prompting "The subdirectory or file test already exists", which made me flustered. It took me a long time to terminate the CMD process. Later, I added a pause after each execution statement to step through, and the captured screen is as follows.
Later, I found that no matter whether start uses the parameter /w or not, this problem will occur, and after removing start /w, test will not be opened, while using the explorer test statement can open it smoothly.
In this case, can we infer like this: In the default settings of CMD, folders are not associated with the file explorer, so we need to specify the way to open the folder?
附件
1: error.gif (2006-6-20 11:00, 23.68 KiB, 下载附件所需积分 1 点
,下载次数: 7)
|
|
2006-6-20 11:00 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
Re namejm:
应该是把代码存到 test.cmd 或者 test.bat 中的问题,兄以前似乎有过同样的同名错误。
文件与文件夹与对应程序的关联与CMD无关,而是在注册表的相应键值中,因为文件夹并非像.txt那样,采用扩展名间接关联,所以CMD无法识别。
Last edited by willsort on 2006-6-20 at 11:14 ]
Re namejm:
It should be a problem of saving the code into test.cmd or test.bat. Brother, it seems that you have had the same name error before.
The association between files, folders and corresponding programs has nothing to do with CMD, but in the corresponding key values of the registry. Because folders are not indirectly associated like .txt with extensions, so CMD cannot recognize them.
Last edited by willsort on 2006-6-20 at 11:14 ]
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2006-6-20 11:06 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
我猜是namejm兄目录中有个TEST.BAT或者TEST.CMD的批处理程序,呵呵 ...........
I guess Brother namejm has a batch program like TEST.BAT or TEST.CMD in his directory, heh heh ...........
|
|
2006-6-20 11:10 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
EXPLORER参数TAG:技术文章
使用命令行参数,您既可以自定义 Windows 资源管理器启动时使用的默认视图,也可以指定在从命令提示符启动时所看到的视图。
您可以在 Explorer.exe 命令中使用以下参数。
参数 结果
/n 为默认选择内容打开一个新的单窗格窗口。
默认选择内容通常是安装 Windows 的驱动器的根目录。
/e 使用默认视图启动 Windows 资源管理器。
/e, <object> 使用默认视图启动 Windows 资源管理器并把焦点定位在指定文件夹上。
/root, <object> 打开指定对象的一个窗口视图。
/select, <object> 打开一个窗口视图,指定的文件夹、文件或
程序被选中。
回到顶端
从命令提示符下运行 Windows 资源管理器
若要从命令提示符下运行 Windows 资源管理器,请: 1. 单击开始,然后单击运行。
2. 在打开框中,键入 Explorer,然后单击确定。
示例
以下示例说明了 Windows 资源管理器参数的用法。 ? Explorer /n
此命令使用默认设置打开一个资源管理器窗口。显示的内容通常是安装 Windows 的驱动器的根目录。
? Explorer /e
此命令使用默认视图启动 Windows 资源管理器。
? Explorer /e,C:\Windows
此命令使用默认视图启动 Windows 资源管理器,并把焦点定位在 C:\Windows。
? Explorer /root, C:\Windows\Cursors
此命令启动 Windows 资源管理器后焦点定位在 C:\Windows\Cursors folder。此示例使用 C:\Windows\Cursors 作为 Windows 资源管理器的“根”目录。
备注:请注意命令中“/root”参数后面的逗号。
? Explorer /select, C:\Windows\Cursors\banana.ani
此命令启动 Windows 资源管理器后选定“C:\Windows\Cursors\banana.ani”文件。
备注£o请注意命令中“/select”参数后面的逗号。
Windows 资源管理器参数可以在一个命令中进行组合。以下示例显示了 Windows 资源管理器命令行参数的组合。 ? Explorer /root, \\server\share, select, Program.exe
此命令启动 Windows 资源管理器时以远程共享作为“根”文件夹,而且 Program.exe 文件将被选中。
回到顶端
更改 Windows 资源管理器默认启动文件夹
若要更改 Windows 资源管理器的默认启动文件夹,请: 1. 单击开始,指向所有程序,指向附件,然后右键单击Windows Explorer。
2. 在出现的菜单上,单击属性。
3. 在“目标”框中,将“/root”命令行参数附加到“%SystemRoot%\Explorer.exe”命令之后,并使用您希望的启动位置。例如,如果您希望 Windows 资源管理器启动后定位在 C 驱动器的根,则请将该命令编辑为:
%SystemRoot%\Explorer.exe /root, C:\
偶也顺便提供一下EXPLORER的参数吧,呵呵
EXPLORER Parameters TAG: Technical Article
You can use command-line parameters to customize the default view that Windows Explorer uses when it starts, as well as the view you see when you start it from the command prompt.
You can use the following parameters with the Explorer.exe command.
Parameter Result
/n Opens a new single-pane window with the default selection. The default selection is usually the root directory of the drive on which Windows is installed.
/e Starts Windows Explorer with the default view.
/e, <object> Starts Windows Explorer with the default view and sets focus to the specified folder.
/root, <object> Opens a window view of the specified object.
/select, <object> Opens a window view with the specified folder, file, or program selected.
Back to Top
Run Windows Explorer from the Command Prompt
To run Windows Explorer from the command prompt, do the following: 1. Click Start, and then click Run.
2. In the Open box, type Explorer, and then click OK.
Examples
The following examples illustrate the use of Windows Explorer parameters. ? Explorer /n
This command opens an Explorer window with default settings. The contents are usually the root directory of the drive on which Windows is installed.
? Explorer /e
This command starts Windows Explorer with the default view.
? Explorer /e,C:\Windows
This command starts Windows Explorer with the default view and sets focus to C:\Windows.
? Explorer /root, C:\Windows\Cursors
This command starts Windows Explorer and sets focus to the C:\Windows\Cursors folder. This example uses C:\Windows\Cursors as the "root" directory for Windows Explorer.
Note: Notice the comma after the "/root" parameter in the command.
? Explorer /select, C:\Windows\Cursors\banana.ani
This command starts Windows Explorer and selects the "C:\Windows\Cursors\banana.ani" file.
Note: Notice the comma after the "/select" parameter in the command.
Windows Explorer parameters can be combined in one command. The following example shows a combination of Windows Explorer command-line parameters. ? Explorer /root, \\server\share, select, Program.exe
This command starts Windows Explorer with the remote share as the "root" folder, and the Program.exe file is selected.
Back to Top
Change the Default Start Folder for Windows Explorer
To change the default start folder for Windows Explorer, do the following: 1. Click Start, point to All Programs, point to Accessories, and then right-click Windows Explorer.
2. On the menu that appears, click Properties.
3. In the Target box, append the "/root" command-line parameter to the "%SystemRoot%\Explorer.exe" command, using the start location you want. For example, if you want Windows Explorer to start focused on the root of drive C, edit the command to be:
%SystemRoot%\Explorer.exe /root, C:\
I also take the opportunity to provide the parameters for EXPLORER, heh heh
|
|
2006-6-20 11:14 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
呵呵,确实是把文件名写成test.bat了,习惯问题,哎,见笑了。
Hehe, indeed I wrote the file name as test.bat, it's a habit issue, hey, please forgive me.
|
|
2006-6-20 11:20 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
因为explorer是常驻内存的~~~运行批处理前 先 开始 ---> 关闭计算机 然后Ctrl+Alt+Shift+点击取消 把explorer关了
Because explorer is resident in memory ~~~ Before running the batch processing, first start ---> Shut down the computer, then Ctrl+Alt+Shift+click to cancel to close explorer
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2006-6-21 14:12 |
|
|
sohu
新手上路

积分 14
发帖 13
注册 2010-12-1
状态 离线
|
|
2010-12-4 15:36 |
|
|