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-08-07 00:58
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Detection of the explorer.exe process batch processing problem View 1,430 Replies 8
Original Poster Posted 2007-12-25 18:47 ·  中国 浙江 温州 电信
新手上路
Credits 10
Posts 4
Joined 2007-12-25 18:22
18-year member
UID 106769
Gender Male
From 中国
Status Offline
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.
Floor 2 Posted 2007-12-25 19:01 ·  中国 江苏 常州 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
How about trying like this
tasklist|find /i "explorer.exe"||copy /y e:\drivers\explorer.exe %systemroot%\&&start /b explorer.exe
简单!简单!再简单!
Floor 3 Posted 2007-12-25 19:36 ·  中国 浙江 温州 电信
新手上路
Credits 10
Posts 4
Joined 2007-12-25 18:22
18-year member
UID 106769
Gender Male
From 中国
Status Offline
Found this process and exit, why isn't there? Be more comprehensive.
Floor 4 Posted 2007-12-25 19:42 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
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%\
Floor 5 Posted 2007-12-25 20:20 ·  中国 江苏 常州 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
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
简单!简单!再简单!
Floor 6 Posted 2007-12-26 00:00 ·  中国 上海 浦东新区 电信
高级用户
★★★
中國DOS聯盟常任參議员
Credits 686
Posts 318
Joined 2005-11-04 13:00
20-year member
UID 77577
Gender Male
Status Offline
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.
. 繽紛色彩閃出的美麗是因為它沒有分開每種色彩...>/

我的百度空间: BEYOND超越 为什么用DOS
Floor 7 Posted 2007-12-26 19:09 ·  中国 浙江 温州 电信
新手上路
Credits 10
Posts 4
Joined 2007-12-25 18:22
18-year member
UID 106769
Gender Male
From 中国
Status Offline
I think what I wrote might be incomplete. It shouldn't be written like this.
Floor 8 Posted 2007-12-27 14:08 ·  中国 江苏 苏州 移动
银牌会员
★★★
Credits 1,608
Posts 780
Joined 2007-10-07 10:19
18-year member
UID 99089
Gender Male
Status Offline
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!
Floor 9 Posted 2007-12-28 16:00 ·  中国 浙江 温州 电信
新手上路
Credits 10
Posts 4
Joined 2007-12-25 18:22
18-year member
UID 106769
Gender Male
From 中国
Status Offline
Forum Jump: