![]() |
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-09-23 14:10 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » [Repost] Asking 3 batch processing questions |
| Printable Version 2,315 / 7 |
| Floor1 foxandmonkey | Posted 2005-04-14 00:00 |
| 初级用户 Posts 23 Credits 129 | |
|
I am a new user who comes here out of admiration. I have encountered several problems and would like to ask for advice. I am used to writing common task modules with batch processing in the use of Windows (although it is not a real DOS in XP).
1. May I ask how to reference the system environment variables in the.bat file, that is, the values obtained by the set command. I have tried using for /F %%f in ('set' do... but it seems not easy to obtain the values of specific variables, and can only use for /F %%f in ('set' do echo %%f to enumerate all. Suppose I now only want to reference the value of the %windir% variable, I don't know how to write it.2. May I ask how to do four arithmetic operations in batch processing? For example, if I echo 1+3, the output is "1+3". If I want to get the sum of 1 plus 3, which is 4, how should I do it? 3. May I ask how to set the local IP and gateway, etc. in the command line? Thank you! Salute! |
|
| Floor2 chenhui530 | Posted 2005-04-14 00:00 |
| 高级用户 Posts 273 Credits 772 | |
|
1, In batch processing, referencing the environment variable is just %%windir%%.
2, set /a a=1+3 echo %a% 3, I remember there is a command to change the IP in XP, but I can't remember it for a moment. You can go check it. |
|
| Floor3 willsort | Posted 2005-04-14 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re chenhui530: Your use of %%windir%% confuses me. Why not just use %windir%? As far as I know, this is only used when outputting to a batch file.
Re foxandmonkey: netsh can change local IP, gateway, DNS and other network settings. A simple example: netsh interface ip set address "Local Area Connection" static 10.0.0.5 255.255.255.0 10.0.0.4 1 |
|
| Floor4 chenhui530 | Posted 2005-04-14 00:00 |
| 高级用户 Posts 273 Credits 772 | |
|
看原文是中文,需要翻译为英文:
Looking at the original poster's meaning, I thought he was going to reference the %windir% variable. Maybe I misunderstood, heh heh~ It's just netsh, I have a bad memory, I just used it the day before yesterday. |
|
| Floor5 foxandmonkey | Posted 2005-04-14 00:00 |
| 初级用户 Posts 23 Credits 129 | |
|
It works! Thanks again to everyone above (this problem has been hanging on pconline.com.cn for two days without a reply)
|
|
| Floor6 foxandmonkey | Posted 2005-04-14 00:00 |
| 初级用户 Posts 23 Credits 129 | |
|
PS. Always wanted to find a list of commonly used command return codes ERRORLEVEL. I don't know which teacher can provide it. Thanks
|
|
| Floor7 willsort | Posted 2005-04-14 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re foxandmonkey:
You can click the following link: http://bbs.cn-dos.net/dispbbs.asp?BoardID=9&ID=13456 In addition, you can refer to the following foreign website for supplementation: http://www.computerhope.com/xdoseror.htm (system error codes, which do not return errorlevel) Finally, these links are only for the return codes of various external commands under DOS 6-7. For the error return codes of commands that update the system, such as reg, fc, etc. under XP, you can view the system help. In addition, it is suggested that new questions be posted as new topics, so that more people can see this question, study and solve this problem; and also let them see this answer, share and discuss this answer. |
|
| Floor8 foxandmonkey | Posted 2005-04-14 00:00 |
| 初级用户 Posts 23 Credits 129 | |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |