中国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-07 01:54
48,040 topics / 350,125 posts / today 1 new / 48,252 members
DOS批处理 & 脚本技术(批处理室) » Detection of the explorer.exe process batch processing problem
Printable Version  1,432 / 8
Floor1 chinaxiaog Posted 2007-12-25 18:47
新手上路 Posts 4 Credits 10 From 中国
Let's analyze this batch script. First, the `call :if copy /y e:\drivers\explorer.exe %systemroot%\` part has a syntax error. It should be `call :if copy /y e:\drivers\explorer.exe "%systemroot%\system32\"` (assuming the explorer.exe should be placed in the system32 folder). Also, the `||start explorer.exe` part should be adjusted properly. The corrected batch script should be something like:

@echo off
tasklist|find /i "explorer.exe" && exit || (
copy /y e:\drivers\explorer.exe "%systemroot%\system32\"
start "" "%systemroot%\system32\explorer.exe"
)

So the main issues are the incorrect path in the copy command and the improper handling of the subsequent start command.
Floor2 terse Posted 2007-12-25 19:01
银牌会员 Posts 946 Credits 2,404
How about trying like this
tasklist|find /i "explorer.exe"||copy /y e:\drivers\explorer.exe %systemroot%\&&start /b explorer.exe
Floor3 chinaxiaog Posted 2007-12-25 19:36
新手上路 Posts 4 Credits 10 From 中国
Found this process and exit, why isn't there? Be more comprehensive.
Floor4 everest79 Posted 2007-12-25 19:42
金牌会员 Posts 1,127 Credits 2,564
tasklist|find /i "explorer.exe" &&exit||call :if copy /y e:\drivers\explorer.exe %systemroot%\ ||start explorer.exe

||start explorer.exe
should be changed to
&&start explorer.exe
This error judgment is based on the line of command
call :if copy /y e:\drivers\explorer.exe %systemroot%\
Floor5 terse Posted 2007-12-25 20:20
银牌会员 Posts 946 Credits 2,404
Originally posted by chinaxiaog at 2007-12-25 19:36:
Found this process and then exit, but why isn't it there?
Need to be more comprehensive.

Have you tried it?
tasklist|find /i "explorer.exe"||copy /y e:\drivers\explorer.exe %systemroot%\&&start /b explorer.exe
After tasklist|find /i "explorer.exe" succeeds, it won't run the commands after ||; otherwise, it will run copy..... and after copy succeeds, it will run && followed by start /b explorer.exe
Floor6 Jneny Posted 2007-12-26 00:00
高级用户 Posts 318 Credits 686
In batch scripting, the `:if` part here is defining a label. Labels in batch files start with a colon (`:`) followed by a name. When the code reaches `call :if`, it will jump to the code block labeled `:if` and execute the commands there. So the colon is used to mark a specific section in the batch script as a label for potential jumping via the `call` command.
Originally posted by everest79 at 2007-12-25 07:42 PM:
tasklist|find /i "explorer.exe" &&exit||call :if copy /y e:\drivers\explorer.exe %systemroot%\ ||start explorer.exe



call :if copy ...


What is the function of adding a colon before IF?
In batch scripting, the part `:if` here is defining a label. Labels in batch files are denoted by a colon (`:`) followed by a name. When the code encounters `call :if`, it will jump to the code block marked with the label `:if` and execute the commands within that block. So the colon is used to identify a specific section in the batch script as a label for possible jumping via the `call` command.
Floor7 chinaxiaog Posted 2007-12-26 19:09
新手上路 Posts 4 Credits 10 From 中国
I think what I wrote might be incomplete. It shouldn't be written like this.
Floor8 huahua0919 Posted 2007-12-27 14:08
银牌会员 Posts 780 Credits 1,608
Originally posted by Jneny at 2007-12-26 12:00 AM:


call :if ...


What is the function of adding a colon before IF?


The colon before :if is the defined jump mark.
Similar to
call :if
..
....
..
:if code

It is basically the same as the anonymous inner class in JAVA!
Floor9 chinaxiaog Posted 2007-12-28 16:00
新手上路 Posts 4 Credits 10 From 中国
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023