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-07-05 08:00
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » I know how to set a password for the operation of a batch file! [Share] View 22,228 Replies 17
Original Poster Posted 2003-04-16 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 186
Posts 17
Joined 2003-04-12 00:00
23-year member
UID 1495
Gender Male
Status Offline
Add in the batch file:
@echo off
choice /c:(password)/n
That's it! For example, if you write "choice /c:a/n", then when you run this batch file, you will be asked for the password. If you enter a, it will continue to run, otherwise you'll just wait!
Note that the password here can only be one digit. If you set 1234 as the password, then entering any of 1, 2, 3, or 4 is considered a correct password. How to improve the confidentiality of the password? You can use ASCII codes. For example, "space" is generated by pressing the number key 255 on the numeric keypad while holding down the ALT key.
Think about it, such a simple method can set a password for the operation of the batch file. Why not do it?!

偶是新手,恳请各路大侠多多指正!
Floor 2 Posted 2003-04-16 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
In this way to set the password can be easily cracked, just press the Ctrl+Break key. If you really want to set a password, still use some batch processing enhancement tools.
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 3 Posted 2003-04-16 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 186
Posts 17
Joined 2003-04-12 00:00
23-year member
UID 1495
Gender Male
Status Offline
This time I don't agree with the moderator's statement!
The syntax of using choice /c: (password)/n is set to prevent others from running this batch file. But you, moderator, said that pressing Ctrl+Break key can easily crack it. Let's ask: Can you continue to run this batch file after pressing it? No! Pressing Ctrl+Break key has the same function as pressing Ctrl+C key, which is to stop the operation, not to skip the password and continue running! This means that your method didn't crack the password I set in the batch file, and you can't run my batch file without entering the correct password!
Haha! It seems I won the first round!
偶是新手,恳请各路大侠多多指正!
Floor 4 Posted 2003-04-16 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
Oh, you mean to continue running? That's also very simple. When running to the CHOICE command and finding a password, first use Ctrl+C to stop the batch file, then use the MORE or TYPE command to view that CHOICE command in the batch file. Because the password is public (you can know it at a glance because there's no encryption), so you can easily know the password; or simply open the batch file for editing and delete those lines of the CHOICE command.

The password set in the batch file is mainly set at startup (especially in AUTOEXEC.BAT), so as to prevent users from using the computer illegally, but if it can be interrupted by users to return to DOS for various operations, then it seems to lose the meaning of encryption.
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 5 Posted 2003-04-17 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 186
Posts 17
Joined 2003-04-12 00:00
23-year member
UID 1495
Gender Male
Status Offline
Maybe I didn't make my actual purpose clear enough.

My original intention was that after locking the computer with my self-written batch file (by modifying the registry to prohibit the operation of all programs, of course, some specified programs can also not be prohibited. For details, see my previous post "One-click Lock Computer Using Batch File", is there any way to encrypt the batch file for unlocking. I personally think my purpose has been achieved, that is, adding a choice statement in the unlocking file, because after I lock the computer, I can't run word processing software.

If you talk about going to DOS to edit and modify this BAT file, then I put it in a very deep Chinese directory, even for you DOS experts, it may be difficult to start for a while?

In fact, everyone understands that the computer can't be absolutely safe. And if the lock is more strict, it will be more inconvenient to unlock. I just want to find a balance between "strict lock" and "convenient unlock". Now, through the guidance of all the experts, my purpose has been basically achieved. There is no computer expert in my unit who can unlock my computer, but I can lock and unlock it in one second (a little exaggerated for a few seconds, hehe...), so this problem will be put aside first. I will discuss it when I have other insights or problems!

Thank you all!
偶是新手,恳请各路大侠多多指正!
Floor 6 Posted 2003-04-18 00:00 ·  中国 山东 菏泽 联通
初级用户
Credits 151
Posts 15
Joined 2003-04-16 00:00
23-year member
UID 1563
Gender Male
Status Offline
Below is the quote from Yang Shangdang on 2003-4-17 20:52:58:
If you say to go down to DOS to edit and modify this BAT file, then I put it in a very deep Chinese directory, even for you DOS experts, it may be difficult to start for a while, right?

Hehe, no matter how deep it is placed in a Chinese directory, it's easy to handle. The security of bat encryption is really not high.
Floor 7 Posted 2003-04-19 00:00 ·  中国 北京 263网络通信股份有限公司
银牌会员
★★★
nre
Credits 1,210
Posts 361
Joined 2002-12-28 00:00
23-year member
UID 629
Gender Male
Status Offline
The following is a quote from Yang Shangdang on 2003-4-17 20:52:58:
Maybe I didn't express my actual purpose clearly enough.
My original intention was that after using the batch file I wrote to lock the computer (by modifying the registry to prohibit the operation of all programs, of course, some specified programs can also not be prohibited. Please refer to my previous post a few days ago "Using Batch Files to One-click Lock the Computer", is there any way to encrypt the batch file used for unlocking. I personally think my purpose has been achieved, that is, adding a choice statement in the unlocking file, because after I lock the computer, I can't run the word processing software.
If you say to go to DOS to edit and modify this BAT file, then I put it in a very deep Chinese directory, even you DOS experts may not be able to start working for a while?
In fact, everyone understands that the computer can't be absolutely safe. And if the lock is tighter, it will be more inconvenient to unlock. I just want to find a balance between "tight lock" and "convenient unlock". Now, through the guidance of all the experts, my purpose has basically been achieved. No one in my unit can unlock my computer, but I can lock and unlock it in one second (a little exaggerated for a few seconds, hehe...), so this problem will be put aside first. I will discuss it when I have other experiences or problems!
Thank you everyone!


The problem is not whether some specified programs are prohibited, but that the user can arbitrarily interrupt the batch process through Ctrl+C. If someone interrupts your AUTOEXEC.BAT, it will completely destroy your encryption and decryption mechanism, and there will be no more talk about it

Teamwork !
Floor 8 Posted 2003-04-19 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 186
Posts 17
Joined 2003-04-12 00:00
23-year member
UID 1495
Gender Male
Status Offline
The following is the speech of nre on 2003-4-19 0:11:16:
The problem is not whether certain specified programs are prohibited, but that users can arbitrarily interrupt the batch processing through Ctrl+C. Once people interrupt your AUTOEXEC.BAT, your encryption and decryption mechanism is completely destroyed, and there is nothing to talk about later

This gentleman may not have read my humble work "Using Batch Files to One-click Lock the Computer": http://www2.zzu.edu.cn/ie/newdos/dispbbs.asp?boardID=12&ID=1814
I don't lock the computer by modifying Autoexec.bat.
偶是新手,恳请各路大侠多多指正!
Floor 9 Posted 2010-07-08 21:10 ·  中国 广东 广州 天河区 电信
初级用户
Credits 28
Posts 15
Joined 2010-06-24 11:49
16-year member
UID 169424
Gender Male
Status Offline
Great
Floor 10 Posted 2010-07-08 22:12 ·  中国 黑龙江 哈尔滨 联通
新手上路
Credits 12
Posts 6
Joined 2010-07-01 19:26
16-year member
UID 169814
Gender Male
Status Offline
Learned, I don't know if the password function works when converting a bat to an exe file
Floor 11 Posted 2010-07-14 16:02 ·  中国 四川 成都 电信
新手上路
Credits 2
Posts 1
Joined 2010-07-12 12:29
15-year member
UID 170439
Gender Male
Status Offline
Learning
Floor 12 Posted 2010-07-19 23:05 ·  中国 广东 惠州 电信
新手上路
Credits 19
Posts 10
Joined 2009-07-07 04:31
16-year member
UID 148892
Gender Male
Status Offline
Learning
Floor 13 Posted 2010-07-26 14:14 ·  中国 广东 梅州 丰顺县 联通
初级用户
Credits 22
Posts 12
Joined 2010-07-24 10:16
15-year member
UID 171101
Gender Male
Status Offline
Still need to learn…
Floor 14 Posted 2010-08-20 10:38 ·  中国 广东 广州 移动
新手上路
Credits 3
Posts 2
Joined 2010-07-07 17:04
15-year member
UID 170162
Gender Male
Status Offline
The number of password digits here can only be one. Then theoretically, isn't the probability of trying it out in 5 attempts quite high?
Floor 15 Posted 2010-08-27 16:47 ·  中国 四川 乐山 电信
新手上路
Credits 4
Posts 19
Joined 2010-08-25 17:50
15-year member
UID 172985
Gender Male
Status Offline
Learning
Forum Jump: