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-01 12:38
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to customize parameters in batch commands? View 2,450 Replies 9
Original Poster Posted 2005-02-20 00:00 ·  中国 黑龙江 哈尔滨 中移铁通
初级用户
Credits 168
Posts 22
Joined 2004-11-18 00:00
21-year member
UID 33761
Gender Male
Status Offline
How to customize parameters in batch commands? I usually use only system parameters. If I want to customize parameters, how should I do it? For example, I made a program with a batch file called test.bat, and I want to add a parameter to it. Thanks. Thanks
Floor 2 Posted 2005-02-20 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
Read more old posts, especially the sticky ones, don't just know to ask.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 3 Posted 2005-02-20 00:00 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
How to define custom parameters for batch commands? The parameters of batch commands are originally input from the command line when you execute it. You can input any parameters you want to give it, from %1 to %9
Floor 4 Posted 2005-02-22 00:00 ·  中国 黑龙江 哈尔滨 中移铁通
初级用户
Credits 168
Posts 22
Joined 2004-11-18 00:00
21-year member
UID 33761
Gender Male
Status Offline
??I'm too noob... still don't understand.... Please everyone take a look at my this program: This batch file's name is test.bat
@echo off
IF "%1"=="o" goto ok
else goto no
: ok
echo dkfjlsfj>>ok.txt
: no
echo dkfjlsfj>>no.txt
I run "test.bat o" but the program didn't make a selection. Just executed both of those two lines.... Don't understand...
Floor 5 Posted 2005-02-22 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
The following is a quote from klot's post on 2005-2-22 11:00:25:

??I'm too noob... still don't understand.... Please take a look at my program:
This batch file is named test.bat
@echo off
IF "%1"=="o" goto ok
else goto no
: ok
echo dkfjlsfj>>ok.txt
: no
echo dkfjlsfj>>no.txt
I run "test.bat o"
But the program didn't make a selection. Just executed both lines.... Don't understand...

Your batch has an issue. Change it as follows:
@echo off
IF "%1"=="o" (goto ok) else (goto no)
: ok
echo dkfjlsfj>>ok.txt
goto end
: no
echo dkfjlsfj>>no.txt
:end
http://www.msfans.net/bbs/
Floor 6 Posted 2005-02-22 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
The more I modify, the more problems there are. What the person upstairs modified can only run in the NT environment.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 7 Posted 2005-02-22 00:00 ·  中国 浙江 绍兴 嵊州市 电信
初级用户
Credits 110
Posts 3
Joined 2005-02-22 00:00
21-year member
UID 36389
Gender Male
Status Offline
It seems there is no "else" in Windows 98 SE?
Floor 8 Posted 2005-02-22 00:00 ·  中国 黑龙江 哈尔滨 中移铁通
初级用户
Credits 168
Posts 22
Joined 2004-11-18 00:00
21-year member
UID 33761
Gender Male
Status Offline
Thanks everyone's help!!! But I'm just straightforward. Climbing, you just talk but don't do. And that post, I really doubt whether you understand DOS. It's better to help everyone solve problems well than to talk so much nonsense if you have time. What I said might be excessive. Please forgive me
Floor 9 Posted 2005-02-22 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
@echo off
IF "%1"=="o" goto ok
goto no

: ok
echo dkfjlsfj>>ok.txt
goto end
: no
echo dkfjlsfj>>no.txt
:end
http://www.msfans.net/bbs/
Floor 10 Posted 2005-02-23 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
The following is the statement made by klot on 2005-2-22 16:51:09:
Thank you all for your help!!! But I'm just outspoken. Climbing, you just talk but don't do. Also, I very much doubt whether that post - maker really understands DOS. It would be better to spend time helping everyone solve problems instead of talking so much nonsense. What I said may be excessive. Please forgive me

Or I don't understand DOS, but I can be certain that those who only know how to ask questions but don't know to check old threads for learning will definitely not learn anything too useful, because it's obvious that you are lacking in the spirit of hard - working study.
If you had taken a little look at the sticky posts, you should have known whether Climbing is the kind of person who talks nonsense and just talks but doesn't do.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Forum Jump: