![]() |
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-02 05:45 |
48,037 topics / 350,122 posts / today 2 new / 48,250 members |
| DOS批处理 & 脚本技术(批处理室) » [Help] A batch file in ghost8? I don't understand! |
| Printable Version 1,454 / 4 |
| Floor1 doslr | Posted 2004-11-12 00:00 |
| 初级用户 Posts 27 Credits 168 | |
|
The code you provided is a batch script related to network configuration and Ghost operations.
For the line `if not "%windir%*"=="*" goto Error`, it's checking if `%windir%` (which is the path to the Windows directory) concatenated with an asterisk is equal to an asterisk alone. Effectively, it's a way to check if `%windir%` is not an empty string. Because if `%windir%` is set (i.e., we're in Windows), then `%windir%*` will be something like `C:\Windows*` which is not equal to `*`, so it will not go to the `Error` label. If `%windir%` is empty (i.e., we're in DOS), then `%windir%*` is just `*`, so it will go to the `Error` label. For the line `if "%3*"=="*" goto Sample`, it's checking if the third command-line argument (`%3`) concatenated with an asterisk is equal to an asterisk alone. This is a way to check if the third command-line argument is empty. If the third argument is empty, then it will go to the `Sample` label. So, in summary: The `*` is used as a way to concatenate with the variable value to perform a check for the presence or absence of the variable's value. The first check is to see if we're in Windows (by checking if `%windir%` is set), and the second check is to see if the third command-line argument is provided. |
|
| Floor2 Climbing | Posted 2004-11-12 00:00 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
In fact, the * here is redundant. When using if to judge whether an environment variable is an empty string, in order to prevent the environment variable from being empty and causing "if %var%==1" to appear as "if ==1", generally, one or more characters are added around the variable to prevent it. The most common way is to enclose the environment variable in double quotes, for example, if "%windir%"==""". Of course, you can also use if %windir%#==# or if %windir%*==* instead of double quotes.
|
|
| Floor3 doslr | Posted 2004-11-16 00:00 |
| 初级用户 Posts 27 Credits 168 | |
|
Heheh, thanks,大侠climbing! It turns out that `if not "%windir%*"=="*"` is to prevent `%windir%` from being empty, leading to a situation where `if not ==*` occurs
|
|
| Floor4 lho | Posted 2004-11-29 00:00 |
| 初级用户 Posts 11 Credits 126 | |
| Floor5 jieok3375 | Posted 2006-10-14 00:44 |
| 中级用户 Posts 130 Credits 282 From 广东 | |
|
Learning
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |