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-12 04:16
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » One-click Lock Computer Using Batch File [Original] View 3,145 Replies 10
Original Poster Posted 2003-04-13 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 186
Posts 17
Joined 2003-04-12 00:00
23-year member
UID 1495
Gender Male
Status Offline
Hello everyone! I'm just a noob. I always admire those who are proficient in DOS. Now through this forum, I've also learned a lot about DOS knowledge. Now I made a self-written batch file (named Norun.bat) which can restrict the use of the computer by modifying the registry. I earnestly ask all experts to give comments!

Here is the content of Norun.bat (for the convenience of narration, paragraph marks are added):

Paragraph 1
pause
Paragraph 2
@ECHO off
regedit -s d:\norun.reg
Paragraph 3
@ECHO off
ren c:\windows\regedit.exe yjf.exe
Paragraph 4
@echo off
ren C:\WINDOWS\SYSBCKUP\RB000.CAB yjf
Paragraph 5
@echo off
attrib "c:\windows\start menu\*.*" +h /s
Paragraph 6
@ECHO off
C:\Windows\Rundll.exe user.exe,exitwindowsexec

Before running this batch file, you must do the preparation work: create "norun.reg", "run.reg" and "Warning Sound.wav" in the D drive.

After running this batch file, the computer will restart forcibly. After self-testing, a warning box will pop up, and then a warning sound will come out from the speaker. That's not all. The desktop is empty, and even no drive is found when opening Windows Explorer. What's worse, it seems that no program can be run!

I will make some annotations on Norun.bat:

Paragraph 1, use the pause command to prevent accidental running.

Paragraph 2 is to merge the norun.reg file into the registry, which is the key to locking the computer. Among them, the role of adding the parameter "-s" after the regedit command is to directly inject the reg file into the registry without confirmation. Now focus on explaining the content of norun.reg:

REGEDIT4


"RestrictRun"=dword:00000001 (Prohibit running any program)
"nodrives"=dword:ffffffff (Hide all drives)
"nodesktop"=dword:00000001 (Hide desktop)


"1"="run.bat" (Allow running run.bat, which is the batch file for unlocking, and the details will be introduced below)
"2"="run.pif" (This refers to allowing running the shortcut of run.bat. If this item is not available, then only the original file of run.bat can be run but not its shortcut when unlocking)
"3"="regedit.exe" (Must allow running the registry editor, otherwise we can't quickly unlock ourselves. As for how to prevent others from running the registry editor, it will be explained below)


"LegalNoticeCaption"="I don't welcome you!!!"
"LegalNoticeText"="Unauthorized use is not allowed!! If you have urgent matters, please contact Yang Shangdang."
(This is the warning box, which will pop up after the computer starts self-testing)


@="D:\\Warning Sound.wav"
(Replaces the original Windows startup sound to further warn illegal users.)

Paragraph 3 is to prevent others from running the registry editor. Rename regedit.exe to "yjf.exe", so those who don't understand can't run the registry editor!

Paragraph 4 is to rename the registry backup file in the system, so as to prevent others from restoring the registry by running "scanreg /restore" under DOS! Brutal, right?

Paragraph 5 is to set all shortcuts in the start menu to hidden attributes, so the start menu will be empty. To achieve this purpose, it must be noted to put the path in quotes, because DOS doesn't recognize file names with spaces!

Paragraph 6 is to command the computer to restart.


Here is the content of the unlocking run.bat:
pause
@echo off
ren c:\windows\yjf.exe regedit.exe
@echo off
attrib "c:\windows\start menu\*.*" -h /s
@ECHO off
regedit -s d:\run.reg

This batch file is very easy to understand, and no need to elaborate here. Only explain the content of run.reg:

REGEDIT4


"RestrictRun"=dword:00000000
"nodesktop"=dword:00000000
"nodrives"=dword:00000000
(Unlock the program, restore the desktop, and restore the display of drives)


"LegalNoticeCaption"=""
"LegalNoticeText"=""
(Remove the warning box)


@="C:\\WINDOWS\\media\\The Microsoft Sound.wav"
(Restore the default sound at startup)
After restarting or logging off, the computer returns to normal.

偶是新手,恳请各路大侠多多指正!
Floor 2 Posted 2003-04-13 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 186
Posts 17
Joined 2003-04-12 00:00
23-year member
UID 1495
Gender Male
Status Offline
Since this is my first post in this forum, I'm a bit nervous. There was an error in the previous post that I need to correct: In the content of norun.reg, the registry entry for hiding the desktop was written as "nodesktop"=dword:00000000. Actually, it should be "nodesktop"=dword:00000001. Very sorry!

I'm really a newbie. I didn't know I could edit my own post! Now I've corrected the error in the previous post. But I want to delete this current post. How can I do that? I beg the moderator to delete this current post of mine! It's really painful to look at!

偶是新手,恳请各路大侠多多指正!
Floor 3 Posted 2003-04-13 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 186
Posts 17
Joined 2003-04-12 00:00
23-year member
UID 1495
Gender Male
Status Offline
You can create a shortcut for "norun.bat" named "norun" and place it in the Start menu. Then, to lock the computer, just press the Windows icon key and then press N. Additionally, create a shortcut for the unlock file "run.bat" and put this shortcut in the Quick Launch toolbar. Then, to unlock, just click it in the Quick Launch toolbar. Do you think this little secret is easy for others to figure out? Actually, for real application, you must definitely encrypt "run.bat". I have been using "Li Wei Encryption System" all the time. It is a very small and easy-to-use free green software. Personally, I think although there are many encryption software nowadays, none is as good as it! Just don't know if it can still be found online now. If any friends are interested, tell me and I'll send it to you.
偶是新手,恳请各路大侠多多指正!
Floor 4 Posted 2003-04-13 00:00 ·  中国 福建 福州 电信
初级用户
Credits 110
Posts 2
Joined 2003-04-13 00:00
23-year member
UID 1508
Gender Male
Status Offline
My e-mail: hover967@hotmail.com Can you send it to me? I'm just looking for this thing : )
Floor 5 Posted 2003-04-14 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 186
Posts 17
Joined 2003-04-12 00:00
23-year member
UID 1495
Gender Male
Status Offline
I have sent the encryption machine to you, please check it!
偶是新手,恳请各路大侠多多指正!
Floor 6 Posted 2003-04-14 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 186
Posts 17
Joined 2003-04-12 00:00
23-year member
UID 1495
Gender Male
Status Offline
May I ask the experts:
I. How to change the attributes of a folder under DOS?
II. Is it possible to require the user to enter a password to continue execution during the execution of a batch file?

偶是新手,恳请各路大侠多多指正!
Floor 7 Posted 2003-04-14 00:00 ·  中国 广东 广州 天河区 电信
中级用户
★★
Credits 347
Posts 54
Joined 2002-12-30 00:00
23-year member
UID 641
Gender Male
Status Offline
Expert!
Floor 8 Posted 2003-04-15 00:00 ·  中国 山东 滨州 联通
高级用户
★★
Credits 948
Posts 271
Joined 2002-12-13 00:00
23-year member
UID 502
Gender Male
From sd
Status Offline
Could you send me the encryption machine? Thanks.
Mail: tanglu_sd@etang.com
Floor 9 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
The following is a quote from tanglu_sd on 2003-4-15 22:50:12:
Could you please send me the encryption machine? Thanks.
Mail:tanglu_sd@etang.com

I have already known how to set a password for the operation of a batch file. Just add the following in the batch file:
@echo off
choice /c:(password)/n. For details, please refer to my post: http://www2.zzu.edu.cn/ie/newdos/dispbbs.asp?boardID=12&ID=1870. However, I will still send you the encryption machine you requested.


偶是新手,恳请各路大侠多多指正!
Floor 10 Posted 2010-08-04 07:09 ·  中国 浙江 嘉兴 电信
初级用户
Credits 28
Posts 25
Joined 2010-08-03 17:09
16-year member
UID 171685
Gender Male
Status Offline
Pass by and I'll also say:
1. Sixth paragraph
@ECHO off
C:\Windows\Rundll.exe user.exe,exitwindowsexec
It doesn't work in my .bat!
2. REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"RestrictRun"=dword:00000001 (Prohibit running any program)
"nodrives"=dword:ffffffff (Hide all drives)
"nodesktop"=dword:00000001 (Hide desktop)
This .reg I directly put into the .bat, this seems simpler.
I'm here for the first time in DOS, please forgive me if I'm wrong.
Floor 11 Posted 2010-08-04 07:24 ·  中国 浙江 嘉兴 电信
初级用户
Credits 28
Posts 25
Joined 2010-08-03 17:09
16-year member
UID 171685
Gender Male
Status Offline
Is what you made here have two .bat and two .reg? I tried and maybe two .exe can be used. Could you please send it to xqxxqx666@163.com Thanks!
Forum Jump: