Using batch processing to realize forbidding running specified program

Time:2021-4-21

Function:
1. Forbid to run the specified program
2. Removal of prohibition designation procedure
three . View all prohibited programs

Copy codeThe code is as follows:
@echo off
MODE con COLS=40 LINES=18
Forbid and cancel the running of specified program — Chen Bing OO: 2865692
:begin
setlocal ENABLEDELAYEDEXPANSION
cls
echo.
echo. ╭─────────╮
echo . ╭ – ╮ select the following operation ╭ – ╮
echo. │ ╰─────────╯ │
echo. │ │
echo . │ A . Add program to be forbidden
echo. │ │
B. delete the forbidden program
echo. │ │
echo . │ C . View all prohibited programs
echo. │ │
Echo. Z. exit program
echo. │ │
echo. ╰─────────────────╯
echo.
copy %systemdrive%\WINDOWS\jzcx %systemdrive%\WINDOWS\jzcx.txt>nul
Set / P enter = please input your choice:
if not “%enter%”==”” set enter=%enter:~0,1%
if /i “%enter%”==”A” goto jinzhiadd
if /i “%enter%”==”B” goto jinzhidel
if /i “%enter%”==”C” goto jinzhick
if /i “%enter%”==”Z” goto exit
goto begin
:jinzhiadd
cls
echo.
echo.
echo . Enter the program to disable: press y to return to the menu
echo.
set /p input=
if /i “%input%”==”Y” goto begin
echo %input%>>%systemdrive%\WINDOWS\jzcx.txt
reg add “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\%input%” /v debugger /t reg_sz /d debugfile.exe /f
echo.
echo . Successfully added program to disable % input %
echo.
echo . Any key to return to other operations
copy %systemdrive%\WINDOWS\jzcx.txt %systemdrive%\WINDOWS\jzcx>nul
pause>nul
goto begin
:jinzhidel
cls
echo.
echo.
echo.
echo.
echo . The procedures for all prohibitions are as follows:
echo ——————————-
echo.
type %systemdrive%\WINDOWS\jzcx.txt
echo.
echo ——————————-
echo.
echo . Enter the forbidden program to delete : Press y to return to the menu
echo.
set /p jinzhidel=
if /i “%jinzhidel%”==”Y” goto begin
reg delete “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\%jinzhidel%” /f
@for /f “tokens=* delims=” %%i in (‘findstr /i /v /c:%jinzhidel% %systemdrive%\WINDOWS\jzcx.txt’) do (
set var=%%i
echo !var!>>temp.txt
)
copy temp.txt %systemdrive%\WINDOWS\jzcx.txt>nul
del temp.txt
cls
echo.
echo.
echo.
echo.
Echo. Operation completed
echo.
echo.
echo . Any key to return to other operations
copy %systemdrive%\WINDOWS\jzcx.txt %systemdrive%\WINDOWS\jzcx>nul
pause>nul
goto begin
:jinzhick
cls
echo.
The procedure of all prohibitions is as follows:
echo ——————————–
echo.
type %systemdrive%\WINDOWS\jzcx.txt
echo.
echo ——————————–
echo.
Any key to return to other operations
pause>nul
goto begin