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 14:35
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » (Problem not yet solved) How to realize man-machine dialogue through commands in batch processing View 3,864 Replies 16
Original Poster Posted 2005-01-29 00:00 ·  中国 海南 三亚 电信
初级用户
Credits 187
Posts 21
Joined 2005-01-22 00:00
21-year member
UID 35554
Gender Male
Status Offline
Is there a command similar to read a under DOS? That is, input a value for variable a. There should be a similar command, right?

The "CHOICE" command can only be used for selection, not for inputting variables. If you set a password in a batch program on a CD, it might not be possible to do it with the "CHOICE" command.

Floor 2 Posted 2005-01-29 00:00 ·  中国 广东 广州 白云区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Your "read a" should be a BASIC statement. There are similar functional commands in DOS: SET. For example: SET A=123. Note that variables defined with SET in DOS are all of character type. When you want to reference a variable, enclose the variable name with two percent signs, such as: echo %a% will display the value of A.
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 3 Posted 2005-02-01 00:00 ·  中国 上海 联通
初级用户
Credits 123
Posts 10
Joined 2005-01-26 00:00
21-year member
UID 35663
Gender Male
Status Offline
set /p

It can achieve the effect you mentioned.

But it is confirmed to be effective in the command line of Windows 2003, and it is unknown under pure DOS.

Floor 4 Posted 2005-02-01 00:00 ·  中国 海南 三亚 电信
初级用户
Credits 187
Posts 21
Joined 2005-01-22 00:00
21-year member
UID 35554
Gender Male
Status Offline
I use the for command \set command \choice command to be able to set a password in batch processing, but the shortcoming is that each letter is displayed in a line when entering the password, and at the same time, the choice.com command must be added in the boot image. I don't know if any old hand can find a better method.

My main idea is as follows:

Call the batch processing www through for %%f in (1 2 3 4 .....N) Note: N is the number of password digits

The content of www.bat:

echo off
choice /c:abcdefghijklmnopqrstuvwxyz /N
if errorlevel 26 goto next26
if errorlevel 25 goto next25
if errorlevel 24 goto next24
if errorlevel 23 goto next23
if errorlevel 22 goto next22
if errorlevel 21 goto next21
if errorlevel 20 goto next20
if errorlevel 19 goto next19
if errorlevel 18 goto next18
if errorlevel 17 goto next17
if errorlevel 16 goto next16
if errorlevel 15 goto next15
if errorlevel 14 goto next14
if errorlevel 13 goto next13
if errorlevel 12 goto next12
if errorlevel 11 goto next11
if errorlevel 10 goto next10
if errorlevel 9 goto next9
if errorlevel 8 goto next8
if errorlevel 7 goto next7
if errorlevel 6 goto next6
if errorlevel 5 goto next5
if errorlevel 4 goto next4
if errorlevel 3 goto next3
if errorlevel 2 goto next2
if errorlevel 1 goto next1
:next26
set readone=z
goto allnext
:next25
set readone=y
goto allnext
:next24
set readone=x
goto allnext
:next23
set readone=w
goto allnext
:next22
set readone=v
goto allnext
:next21
set readone=u
goto allnext
:next20
set readone=t
goto allnext
:next19
set readone=s
goto allnext

:next18
set readone=r
goto allnext
:next17
set readone=q
goto allnext
:next16
set readone=p
goto allnext
:next15
set readone=o
goto allnext
:next14
set readone=n
goto allnext
:next13
set readone=m
goto allnext
:next12
set readone=l
goto allnext

:next11
set readone=k
goto allnext
:next10
set readone=j
goto allnext
:next9
set readone=i
goto allnext
:next8
set readone=h
goto allnext
:next7
set readone=g
goto allnext
:next6
set readone=f
goto allnext
:next5
set readone=e
goto allnext
:next4
set readone=d
goto allnext
:next3
set readone=c
goto allnext
:next2
set readone=b
goto allnext
:next1
set readone=a
:allnext
set userpw=%userpw%%readone%
The program is probably like this, which can achieve the purpose, but it is very annoying, and the password is not entered all at once. I don't know if anyone has a good method?
Floor 5 Posted 2005-02-01 00:00 ·  中国 上海 静安区 电信
初级用户
Credits 123
Posts 10
Joined 2005-01-26 00:00
21-year member
UID 35663
Gender Male
Status Offline
@echo off

:set_password

set /p password=

set userpw=%userpw%%password%

goto set_password
Floor 6 Posted 2005-02-02 00:00 ·  中国 四川 自贡 电信
初级用户
Credits 187
Posts 31
Joined 2004-08-30 00:00
21-year member
UID 30979
Gender Male
Status Offline
Assuming your batch file name is password.bat with the following command: call w.bat box @password.bat:ddddd Write other code here. The entered content has been stored in variable %password%:ddddd Please enter password ::The defect of this method is that two files, wbat and w.bat, are needed and it needs to be placed in a virtual memory disk because there is file writing operation
Floor 7 Posted 2005-02-03 00:00 ·  中国 海南 三亚 电信
初级用户
Credits 187
Posts 21
Joined 2005-01-22 00:00
21-year member
UID 35554
Gender Male
Status Offline
Here is the speech by shella on 2005-2-2 1:24:58:

You can use wbat.
Suppose the name of your batch file is password.bat
You need the following command
call w.bat box @password.bat:ddddd
Write other code here, and the entered content has been stored in the variable %password%
:ddddd
Please enter the password

::
The defect of this method is that two files, wbat and w.bat, are needed
In addition, it needs to be put into a virtual memory disk because there is a file writing operation

Can you explain in detail how to use wbat and w.bat? In what environment are wbat and w.bat used?
Floor 8 Posted 2005-02-03 00:00 ·  中国 四川 自贡 电信
初级用户
Credits 187
Posts 31
Joined 2004-08-30 00:00
21-year member
UID 30979
Gender Male
Status Offline
wbat is a dialog-making software under DOS (not applicable to 2k/XP, I don't know about 98). w.bat is an advanced usage of wbat, used to assign input content to variables. For parameters, you can check my post: http://dos.e-stone.cn/dosbbs/dispbbs.asp?boardID=12&ID=14979&page=1
Floor 9 Posted 2005-02-05 00:00 ·  中国 海南 三亚 电信
初级用户
Credits 187
Posts 21
Joined 2005-01-22 00:00
21-year member
UID 35554
Gender Male
Status Offline
The following is the statement made by shella on 2005-2-3 20:23:27:

wbat is a dialog box making software under DOS (cannot be used for 2k/XP, I don't know about 98)
w.bat is an advanced usage of wbat, used to assign the input content to a variable
For using parameters, you can check my post
http://dos.e-stone.cn/dosbbs/dispbbs.asp?boardID=12&ID=14979&page=1

May I ask where to download wbat, and can it be used to make a bootable disk?
Floor 10 Posted 2005-02-06 00:00 ·  中国 上海 静安区 电信
初级用户
Credits 123
Posts 10
Joined 2005-01-26 00:00
21-year member
UID 35663
Gender Male
Status Offline
Is my batch processing incorrect?

And no external commands are needed.
Floor 11 Posted 2005-02-07 00:00 ·  中国 四川 自贡 电信
初级用户
Credits 187
Posts 31
Joined 2004-08-30 00:00
21-year member
UID 30979
Gender Male
Status Offline
At the end of the first post
Can be used for boot disks
But note that if you want to use the advanced method, you need to copy these files to the virtual memory disk and run them
Because writing operations are required
Floor 12 Posted 2005-02-15 00:00 ·  中国 湖南 长沙 电信
高级用户
★★
Credits 772
Posts 273
Joined 2004-10-23 00:00
21-year member
UID 32861
Gender Male
Status Offline
You can edit in AUTOEXEC.BAT and then call WBAT to achieve password access, but the disadvantage is that the security is still not high. Once others use an editing software to open AUTOEXEC.BAT, they will understand it.
http://www.msfans.net/bbs/
Floor 13 Posted 2005-02-16 00:00 ·  中国 四川 自贡 电信
初级用户
Credits 187
Posts 31
Joined 2004-08-30 00:00
21-year member
UID 30979
Gender Male
Status Offline
Use bat2com to convert another saved password processing bat into a com file, and then call it in autoexec.bat
Floor 14 Posted 2005-02-24 00:00 ·  中国 福建 泉州 石狮市 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
Save this as a batch file and then modify it as needed.
@echo off
:: Set the initial password to only use lowercase letters and numbers
set pass=chenallqq368178720
:: Input password and verify
:pass
cls
echo.
echo.
echo. Please input your password!
echo.
echo. Password:%xxx%
choice /c:abcdefghijklmnopqrstuvwxyz1234567890 /N
if errorlevel 1 set chk=a
if errorlevel 2 set chk=b
if errorlevel 3 set chk=c
if errorlevel 4 set chk=d
if errorlevel 5 set chk=e
if errorlevel 6 set chk=f
if errorlevel 7 set chk=g
if errorlevel 8 set chk=h
if errorlevel 9 set chk=i
if errorlevel 10 set chk=j
if errorlevel 11 set chk=k
if errorlevel 12 set chk=l
if errorlevel 13 set chk=m
if errorlevel 14 set chk=n
if errorlevel 15 set chk=o
if errorlevel 16 set chk=p
if errorlevel 17 set chk=q
if errorlevel 18 set chk=r
if errorlevel 19 set chk=s
if errorlevel 20 set chk=t
if errorlevel 21 set chk=u
if errorlevel 22 set chk=v
if errorlevel 23 set chk=w
if errorlevel 24 set chk=x
if errorlevel 25 set chk=y
if errorlevel 26 set chk=z
if errorlevel 27 set chk=1
if errorlevel 28 set chk=2
if errorlevel 29 set chk=3
if errorlevel 30 set chk=4
if errorlevel 31 set chk=5
if errorlevel 32 set chk=6
if errorlevel 33 set chk=7
if errorlevel 34 set chk=8
if errorlevel 35 set chk=9
if errorlevel 36 set chk=0
set input=%input%%chk%
set xxx=%xxx%*
:: Password check, if correct then exit
if #%pass%==#%input% goto end
goto pass
:end
If you enter chenallqq368178720 in sequence after running, it will exit; otherwise.........
This is a password-checking batch file. It can be modified to become a password-setting batch file.
QQ:366840202
http://chenall.net
Floor 15 Posted 2005-02-24 00:00 ·  中国 福建 泉州 石狮市 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
Here is the speech of Denver quoted on 2005-2-6 0:03:34:
Is my batch processing incorrect?



No external commands are needed.


There is nothing wrong with this command. It just can only be used in systems above WINDOWS 2000.
QQ:366840202
http://chenall.net
Forum Jump: