中国DOS联盟论坛

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-21 05:29
47,812 topics / 349,917 posts / today 0 new / 48,270 members
DOS学习入门 & 精彩文章 (教学室) » I know how to set a password for the operation of a batch file! [Share]
Printable Version  23,135 / 17
Floor1 杨上当 Posted 2003-04-16 00:00
初级用户 Posts 17 Credits 186
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?!

Floor2 Wengier Posted 2003-04-16 00:00
系统支持 Posts 10,521 Credits 27,736
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.
Floor3 杨上当 Posted 2003-04-16 00:00
初级用户 Posts 17 Credits 186
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!
Floor4 Wengier Posted 2003-04-16 00:00
系统支持 Posts 10,521 Credits 27,736
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.
Floor5 杨上当 Posted 2003-04-17 00:00
初级用户 Posts 17 Credits 186
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!
Floor6 Silence Posted 2003-04-18 00:00
初级用户 Posts 15 Credits 151
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.
Floor7 nre Posted 2003-04-19 00:00
银牌会员 Posts 361 Credits 1,210
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
Floor8 杨上当 Posted 2003-04-19 00:00
初级用户 Posts 17 Credits 186
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.
Floor9 WUYAN520 Posted 2010-07-08 21:10
初级用户 Posts 15 Credits 28
Great
Floor10 fxdf Posted 2010-07-08 22:12
新手上路 Posts 6 Credits 12
Learned, I don't know if the password function works when converting a bat to an exe file
Floor11 HkPs Posted 2010-07-14 16:02
新手上路 Posts 1 Credits 2
Learning
Floor12 a7147125 Posted 2010-07-19 23:05
新手上路 Posts 10 Credits 19
Learning
Floor13 panyanyany Posted 2010-07-26 14:14
初级用户 Posts 12 Credits 22
Still need to learn…
Floor14 vergr Posted 2010-08-20 10:38
新手上路 Posts 2 Credits 3
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?
Floor15 jfcjb Posted 2010-08-27 16:47
新手上路 Posts 19 Credits 4
Learning
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023