中国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-08-12 10:05
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » Self-written small tool: Enhance the security of .bat, .cmd, and .reg files in the system
Printable Version  3,504 / 10
Floor1 bootp Posted 2006-11-30 12:35
初级用户 Posts 25 Credits 66
```
::===========================================================================
@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===================================
```

Attachments
FileSafe.bat.rar (1.47 KiB)
FileSafe.exe.rar (60.89 KiB)
Floor2 vkill Posted 2006-12-01 07:52
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
There are so many useless things before, hey
Floor3 weihua1983 Posted 2006-12-01 08:13
初级用户 Posts 10 Credits 20
Floor4 6622186 Posted 2007-03-14 03:25
高级用户 Posts 411 Credits 894
You can directly modify the registry using reg without using .reg files, so that temporary files are not generated.
Floor5 6622186 Posted 2007-03-14 03:49
高级用户 Posts 411 Credits 894
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.
Floor6 yangcg Posted 2007-03-16 12:54
新手上路 Posts 2 Credits 4
Floor7 htysm Posted 2007-03-17 04:44
高级用户 Posts 415 Credits 866
Nice
Floor8 heicai Posted 2007-03-17 05:20
中级用户 Posts 156 Credits 385
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
Floor9 njccav Posted 2010-09-07 20:37
新手上路 Posts 2 Credits 2
Floor10 liangshenda Posted 2010-12-25 00:50
新手上路 Posts 6 Credits 8
Thanks
Floor11 acaigg Posted 2010-12-27 19:51
初级用户 Posts 92 Credits 115
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023