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-07-02 20:46
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Discussion]Specialty of the explorer process View 3,255 Replies 11
Original Poster Posted 2006-06-20 10:25 ·  中国 山西 大同 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 2 Posted 2006-06-20 10:40 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
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.............
Floor 3 Posted 2006-06-20 10:44 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
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........
Floor 4 Posted 2006-06-20 10:48 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
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.
Floor 5 Posted 2006-06-20 10:51 ·  中国 山西 大同 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 6 Posted 2006-06-20 11:00 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
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?
Attachments
error.gif
Floor 7 Posted 2006-06-20 11:06 ·  中国 山西 大同 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 8 Posted 2006-06-20 11:10 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
I guess Brother namejm has a batch program like TEST.BAT or TEST.CMD in his directory, heh heh ...........
Floor 9 Posted 2006-06-20 11:14 ·  中国 北京 联通
银牌会员
★★★
DOS联盟捡破烂的
Credits 1,144
Posts 425
Joined 2005-10-20 00:00
20-year member
UID 43784
From 北京
Status Offline
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
Floor 10 Posted 2006-06-20 11:20 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Hehe, indeed I wrote the file name as test.bat, it's a habit issue, hey, please forgive me.
Floor 11 Posted 2006-06-21 14:12 ·  IANA 局域网IP(Private-Use)
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
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'>"
Floor 12 Posted 2010-12-04 15:36 ·  中国 广东 东莞 电信
新手上路
Credits 14
Posts 13
Joined 2010-12-01 15:41
15-year member
UID 178657
Gender Male
Status Offline
have only a partial understanding
Forum Jump: