![]() |
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 16:24 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » (Problem not yet solved) How to realize man-machine dialogue through commands in batch processing |
| Printable Version 4,267 / 16 |
| Floor1 mtx | Posted 2005-01-29 00:00 |
| 初级用户 Posts 21 Credits 187 | |
|
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. |
|
| Floor2 JonePeng | Posted 2005-01-29 00:00 |
| 金牌会员 Posts 1,883 Credits 4,562 From 广东广州 | |
|
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.
|
|
| Floor3 Denver | Posted 2005-02-01 00:00 |
| 初级用户 Posts 10 Credits 123 | |
|
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. |
|
| Floor4 mtx | Posted 2005-02-01 00:00 |
| 初级用户 Posts 21 Credits 187 | |
|
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? |
|
| Floor5 Denver | Posted 2005-02-01 00:00 |
| 初级用户 Posts 10 Credits 123 | |
|
@echo off
:set_password set /p password= set userpw=%userpw%%password% goto set_password |
|
| Floor6 shella | Posted 2005-02-02 00:00 |
| 初级用户 Posts 31 Credits 187 | |
|
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
|
|
| Floor7 mtx | Posted 2005-02-03 00:00 |
| 初级用户 Posts 21 Credits 187 | |
Here is the speech by shella on 2005-2-2 1:24:58: Can you explain in detail how to use wbat and w.bat? In what environment are wbat and w.bat used? |
|
| Floor8 shella | Posted 2005-02-03 00:00 |
| 初级用户 Posts 31 Credits 187 | |
|
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
|
|
| Floor9 mtx | Posted 2005-02-05 00:00 |
| 初级用户 Posts 21 Credits 187 | |
The following is the statement made by shella on 2005-2-3 20:23:27: May I ask where to download wbat, and can it be used to make a bootable disk? |
|
| Floor10 Denver | Posted 2005-02-06 00:00 |
| 初级用户 Posts 10 Credits 123 | |
|
Is my batch processing incorrect?
And no external commands are needed. |
|
| Floor11 shella | Posted 2005-02-07 00:00 |
| 初级用户 Posts 31 Credits 187 | |
|
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 |
|
| Floor12 chenhui530 | Posted 2005-02-15 00:00 |
| 高级用户 Posts 273 Credits 772 | |
|
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.
|
|
| Floor13 shella | Posted 2005-02-16 00:00 |
| 初级用户 Posts 31 Credits 187 | |
|
Use bat2com to convert another saved password processing bat into a com file, and then call it in autoexec.bat
|
|
| Floor14 chenall | Posted 2005-02-24 00:00 |
| 银牌会员 Posts 469 Credits 1,276 From 福建泉州 | |
|
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. |
|
| Floor15 chenall | Posted 2005-02-24 00:00 |
| 银牌会员 Posts 469 Credits 1,276 From 福建泉州 | |
Here is the speech of Denver quoted on 2005-2-6 0:03:34: There is nothing wrong with this command. It just can only be used in systems above WINDOWS 2000. |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |