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-06-25 03:29
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Self-written small tool: Enhance the security of .bat, .cmd, and .reg files in the system View 3,258 Replies 10
Original Poster Posted 2006-11-30 12:35 ·  中国 河南 濮阳 电信
初级用户
Credits 66
Posts 25
Joined 2006-11-26 14:33
19-year member
UID 71807
Gender Male
Status Offline
```
::===========================================================================
@ECHO OFF

ECHO intAnswer = Msgbox("This software resets the default opening method of .BAT, .CMD, and .REG files from the original 'Run' to 'View'. In this way, files won't be directly executed when accidentally double-clicked, which can effectively avoid misoperations and enhance system security.", vbExclamation, "File Security Enhancement Tool: Batch BAT Files, Command Script CMD Files, Registry REG Files")>%Temp%\Temp.vbs
%Temp%\Temp.vbs

ECHO REGEDIT4 >TEMP.TXT
ECHO. >>TEMP.TXT
ECHO >>TEMP.TXT
ECHO @="Edit(&E)" >>TEMP.TXT
ECHO >>TEMP.TXT
ECHO @="Edit(&E)" >>TEMP.TXT
ECHO >>TEMP.TXT
ECHO @="edit" >>TEMP.TXT
ECHO >>TEMP.TXT
ECHO @="Edit(&E)" >>TEMP.TXT
ECHO >>TEMP.TXT
ECHO @="notepad.exe \"%%1\"" >>TEMP.TXT
ECHO >>TEMP.TXT
ECHO "NullFile"="" >>TEMP.TXT

regedit /S TEMP.TXT
DEL TEMP.TXT

ECHO intAnswer = Msgbox("Settings successful! The default opening method of batch BAT files, command script CMD files, and registry REG files has been reset from the original 'Run' to 'View'. Please click 'OK' to exit.", vbExclamation, "File Security Enhancement Tool Execution Completed!")>%Temp%\Temp.vbs
%Temp%\Temp.vbs
DEL %Temp%\Temp.vbs

::===========================================================================
::
::How to restore the original system settings? Just save the following code as a BAT file and import it into the system.
::
::Uninstall program:
::
::@ECHO OFF
::ECHO REGEDIT4 >TEMP.TXT
::ECHO. >>TEMP.TXT
::ECHO >>TEMP.TXT
::ECHO @="" >>TEMP.TXT
::ECHO >>TEMP.TXT
::ECHO @="" >>TEMP.TXT
::ECHO >>TEMP.TXT
::ECHO @="open" >>TEMP.TXT
::ECHO >>TEMP.TXT
::regedit /S TEMP.TXT
::DEL TEMP.TXT
::
::===========================================================================
::  Increase the security of.bat,.cmd, and.reg files in the system
::
::
::Applicable to: Windows98/WindowsMe/WindowsNT/Windows2000/WindowsXP operating systems.
::
::
::
::   Windows98, WindowsMe, Windows NT, Windows2000, and WindowsXP are operating systems that everyone is using. Among these operating systems, there are three types of files that are prone to system exceptions or errors if not operated carefully. These three types of files are: MS-DOS command batch files, WINDOWS NT command script files, and registry files, with extensions.bat,.cmd, and.reg respectively. The reason why these three types of files have poor fault tolerance is that the default opening method of these three types of files in the system is Run, that is, if these files are accidentally double-clicked, the files will be directly executed. And executing these three types of files is very likely to cause registry damage or system exceptions.
::
::  To solve this problem, Rouren made something to strengthen these three files. The principle of reinforcement is that the above three types of files are all text files. Change the default opening method to View, that is, when double-clicked, these files will not be directly executed but opened by Notepad for viewing and editing. And the "Run" or "Import" of these files needs to be started by clicking the corresponding option in the right-click shortcut menu.
::
::  In this way, you don't have to worry about accidentally double-clicking these three types of dangerous files anymore, and the stability and fault tolerance of the system are enhanced.
::
::
::===========================================================================
::
::  Giving roses, leaving fragrance. If you are satisfied, don't forget to send a copy to your friends.
::Rouren sincerely hopes to help you and your friends increase a bit of fun in using the computer and reduce a bit of trouble in using the computer.
::
::  Welcome to use, please keep the code complete. Contact Rouren: bootp@126.com
::
::=====================================EOF===================================
```
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
redtek +3 2006-11-30 12:47
heicai +2 2007-03-17 05:19
Attachments
FileSafe.bat.rar (1.47 KiB, Credits to download 1 pts, Downloads: 47)
FileSafe.exe.rar (60.89 KiB, Credits to download 1 pts, Downloads: 50)
Floor 2 Posted 2006-12-01 07:52 ·  中国 甘肃 兰州 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
There are so many useless things before, hey
Floor 3 Posted 2006-12-01 08:13 ·  中国 江西 赣州 安远县 电信
初级用户
Credits 20
Posts 10
Joined 2006-10-19 01:04
19-year member
UID 66622
Gender Male
Status Offline
Floor 4 Posted 2007-03-14 03:25 ·  中国 湖北 潜江 电信
高级用户
★★★
Credits 894
Posts 411
Joined 2007-02-17 12:15
19-year member
UID 79697
Gender Male
Status Offline
You can directly modify the registry using reg without using .reg files, so that temporary files are not generated.
@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul


Floor 5 Posted 2007-03-14 03:49 ·  中国 湖北 潜江 电信
高级用户
★★★
Credits 894
Posts 411
Joined 2007-02-17 12:15
19-year member
UID 79697
Gender Male
Status Offline
It turns out that the files imported by regeidt don't have to be only .reg files; text files can also be used. The .reg file is just for double - clicking the .reg file or entering the file name in the Run window and command line. The regedit command isn't restricted by the file extension.
@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul


Floor 6 Posted 2007-03-16 12:54 ·  中国 新疆 昌吉回族自治州 昌吉市 电信
新手上路
Credits 4
Posts 2
Joined 2007-03-11 03:14
19-year member
UID 81361
Gender Male
Status Offline
Floor 7 Posted 2007-03-17 04:44 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
Nice
Floor 8 Posted 2007-03-17 05:20 ·  中国 浙江 宁波 电信
中级用户
★★
Credits 385
Posts 156
Joined 2007-01-19 02:32
19-year member
UID 76955
Gender Male
Status Offline
Originally posted by 6622186 at 2007-3-13 02:49 PM:
It turns out that the file imported by regeidt doesn't have to be a .reg file; a txt file can also work. The .reg file is just for double-clicking the .reg file or entering the file name in the Run window and command line. The regedit command is not restricted by the file extension.

Learned these things again. Thanks
Floor 9 Posted 2010-09-07 20:37 ·  中国 四川 内江 电信
新手上路
Credits 2
Posts 2
Joined 2010-05-01 15:35
16-year member
UID 165915
Gender Male
Status Offline
Floor 10 Posted 2010-12-25 00:50 ·  中国 广东 汕尾 电信
新手上路
Credits 8
Posts 6
Joined 2006-02-04 13:51
20-year member
UID 49830
Status Offline
Thanks
Floor 11 Posted 2010-12-27 19:51 ·  中国 广东 东莞 中移铁通
初级用户
★★
Credits 115
Posts 92
Joined 2010-12-24 16:57
15-year member
UID 179794
Gender Male
Status Offline
Forum Jump: