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-09 19:39
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to disable CMD View 3,671 Replies 20
Original Poster Posted 2008-09-11 18:13 ·  中国 浙江 杭州 电信
初级用户
★★
Credits 155
Posts 74
Joined 2007-02-21 07:24
19-year member
UID 79875
Gender Male
Status Offline
By modifying the registry, you can prohibit users from using the command interpreter (CMD.exe) and running batch files (BAT files).

Enter the registry key
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\,
create a double-byte value item DisableCMD, and modify its value to 2.
Then both the command interpreter and batch files cannot be run.
If you only want to prohibit the running of the command interpreter but allow the running of batch files, modify the value of DisableCMD to 1.

Both 1 and 2 are prohibitions, so what is 0? Of course, there are no restrictions.

I saw a method to disable the registry by modifying the registry, which works well, but I want to implement it with a batch file. I don't know how to modify it. Please help me, masters. I also want to learn how to modify the registry with a batch file. The more detailed the better. Thank you!
Floor 2 Posted 2008-09-11 18:31 ·  中国 江苏 苏州 中移铁通
银牌会员
★★★
Credits 1,608
Posts 780
Joined 2007-10-07 10:19
18-year member
UID 99089
Gender Male
Status Offline
After modifying to 1, neither works. After modifying to 2, it has no effect winXP-SP2@cmd
Floor 3 Posted 2008-09-11 18:37 ·  中国 浙江 杭州 电信
初级用户
★★
Credits 155
Posts 74
Joined 2007-02-21 07:24
19-year member
UID 79875
Gender Male
Status Offline
Thanks to the correction from user 2, but how to implement it!
Floor 4 Posted 2008-09-11 18:44 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
The command-line tool reg.exe is used to operate the registry. Type reg /? to view the help.

=======================
Using "image hijacking" can disable the running of cmd.exe and batch processing simultaneously.
Disable
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cmd.EXE" /v debugger /t reg_sz /d debugfile.exe /f

Restore

reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cmd.exe" /f


[ Last edited by tireless on 2008-9-10 at 10:47 PM ]
Floor 5 Posted 2008-09-11 18:49 ·  中国 江苏 苏州 中移铁通
银牌会员
★★★
Credits 1,608
Posts 780
Joined 2007-10-07 10:19
18-year member
UID 99089
Gender Male
Status Offline
You wrote HKLM, so you can't find it
Floor 6 Posted 2008-09-11 18:52 ·  中国 浙江 杭州 电信
初级用户
★★
Credits 155
Posts 74
Joined 2007-02-21 07:24
19-year member
UID 79875
Gender Male
Status Offline
Thank you, friend on the 4th floor. You helped me solve the problem, but it's useless to post it back because you've prohibited running. Can your restored batch file still run? But I'm very grateful!
Floor 7 Posted 2008-09-11 20:42 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
The recovery can use this method: generate a.reg file and then import it into the registry.
Floor 8 Posted 2008-09-11 22:56 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Originally posted by mfdcxnf at 2008-9-10 10:52 PM:
Thanks to the friend on the 4th floor, you helped me solve the problem, but it's useless for you to post the recovery because you have prohibited running. Can your recovery batch processing still run? But thank you very much!

Run directly in the "Run" dialog box.
Floor 9 Posted 2008-09-11 23:06 ·  中国 广东 东莞 电信
中级用户
★★
Credits 461
Posts 243
Joined 2007-10-14 16:56
18-year member
UID 99730
Gender Male
Status Offline
How to set up disabling Windows scripts?
Floor 10 Posted 2008-09-12 20:16 ·  中国 浙江 杭州 电信
初级用户
★★
Credits 155
Posts 74
Joined 2007-02-21 07:24
19-year member
UID 79875
Gender Male
Status Offline
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Hidden /t reg_dword /d 00000000 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t reg_dword /d 00000001 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowSuperHidden /t reg_dword /d 00000000 /f
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v Disableregistrytools /t REG_DWORD /d 1
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cmd.EXE" /v debugger /t reg_sz /d debugfile.exe /f

In this way, it cannot be restored with REG. If anyone has a good move, please share it. Thank you! I want to be able to use it when I need it and prohibit it when I don't!
I don't know if the script can realize removing the prohibition. Batch processing and registry are definitely not okay.

[ Last edited by mfdcxnf on 2008-9-12 at 08:18 PM ]
Floor 11 Posted 2008-09-12 21:59 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Is xxx.inf okay?

Signature="$CHICAG0$"

AddReg=My.Add.Reg:

HKCU,"SOFTWARE\Microsoft\windows\currentversion\policies\system","disableregistrytools",0x00010001,"0"


What about xxx.vbs?
Dim WSHShell
Set WSHShell =CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCU\SOFTWARE\Microsoft\windows\currentversion\policies\system\disableregistrytools",0, "REG_DWORD"


[ Last edited by HAT on 2008-9-15 at 04:37 PM ]
Floor 12 Posted 2008-09-13 07:19 ·  中国 浙江 杭州 电信
初级用户
★★
Credits 155
Posts 74
Joined 2007-02-21 07:24
19-year member
UID 79875
Gender Male
Status Offline
I have tested the code from the user above, but it still doesn't work
Floor 13 Posted 2008-09-13 09:49 ·  中国 重庆 九龙坡区 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
The code on floor 11 cannot unlock the registry? What is the error message?
Floor 14 Posted 2008-09-13 11:00 ·  中国 广东 广州 电信
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
It can't run on my machine either, and the error message is shown in the following picture:

Floor 15 Posted 2008-09-13 13:04 ·  中国 广东 广州 番禺区 电信
高级用户
★★
我思故我在
Credits 512
Posts 228
Joined 2007-01-21 10:31
19-year member
UID 77225
Gender Male
Status Offline
Could it be that your computer has deleted several host files that interpret VBS operations? I remember some internet cafes do this like that
我确实是只菜鸟,而且这里X人太多,所以我不敢装X。谁要再说我装X,我就XXOO他。
Forum Jump: