@echo off
:home
cd c:/
IF EXIST "%PROGRAMFILES(X86)%" (set bit=x64) ELSE (set bit=x86)
title Log in to CMD
color f0
cls
echo.
echo Cmd Accounts
echo ======================================
echo.
echo [1] Log In (access existing Account)
echo.
echo [2] Register (add an account)
echo.
echo [3] Delete Account (remove an account)
echo.
echo ============Ethans Security===========
echo.
set RegisterVal=0
set DeleteAcc=0
set /p op=
if %op%==1 goto Login
if %op%==2 goto setReg
if %op%==3 goto setDel
goto home
:setReg
set RegisterVal=1
goto Login
:setDel
set DeleteAcc=1
goto Login
:Login
cls
cd c:/
mkdir enxlogin
cd enxlogin
cls
echo Cmd Login
echo ======================================
echo.
set /p logName="Enter your username:"
EditV64 -m -p 'Enter your Password:' logPass
EditV32 -m -p 'Enter your Password:' logPass
if exist %logName%.txt goto continue
cls
color fc
echo Cmd Login
echo ======================================
echo.
echo Acces Denied
pause
goto home
:continue
set /p var= <%logName%.txt
set actPass=%var%
call enx actPass actPass
if %logPass%==%actPass% goto logdone
color fc
cls
echo Cmd Login
echo ======================================
echo.
echo Acces Denied
pause
goto home
:Register
cd c:/
mkdir enxlogin
cd enxlogin
cls
echo Cmd Register
echo ======================================
echo.
set /p regName="Enter new username:"
set /p regPass="Enter new password:"
set regName=%regName%
set regPass=%regPass%
call enx regPass regPass
echo %regPass%>%regName%.txt
set regName=NUL
set regPass=NUL
cls
echo Cmd Register
echo ======================================
echo.
echo Acount Successfully Created
echo.
pause
goto home
:DelAccount
cd c:/
mkdir enxlogin
cd enxlogin
cls
echo Cmd Delete Account
echo ======================================
echo.
echo Account List
echo ------------
for %%a in ("c:\enxlogin\*") do @echo %%~na
echo.
echo Enter the Account you want to delete:
set /p deletingAcc="Account Name:"
if exist %deletingAcc%.txt goto delaccountnow
cls
echo Account not found
pause
goto DelAccount
echo Cmd Delete Account
echo ======================================
echo.
:delaccountnow
del %deletingAcc%.txt
cls
echo Cmd Delete Account
echo ======================================
echo.
echo Successfully Deleted Account
pause
goto home
:logdone
if %RegisterVal%==1 goto Register
if %DeleteAcc%==1 goto DelAccount
set Register=0
set actPass=NUL
set logPass=NUL
cls
echo Cmd Login
echo ======================================
echo.
echo Successfully logged in!
echo.
pause
color 0f
cd "%userprofile%\Desktop"
cls
exit
这是我的批处理密码脚本,它在启动cmd或批处理文件时运行,但是当用户按ctrl-c或ctrl-break时,它将绕过登录脚本
这是我运行cmd时发生的事情,它将启动所有工作,但是当我按CTRL-C时,它退出并返回到正常CMD,因此您可以将cmd弄乱了,这是一种防范措施,目的是保护人们免于以一种酷炫的方式弄乱我的cmd
最佳答案
下面的批处理文件无法通过Ctrl-C取消,并且如果通过Ctrl-Break取消,则cmd.exe窗口将关闭,因此用户将永远无法通过此批处理文件访问正常的cmd.exe命令行会话。 。
@echo off
setlocal
if "%~1" equ "NonCancelable" goto NonCancelable
start "" /B cmd /C "%~F0" NonCancelable
exit
:NonCancelable
echo You can NOT cancel me!
echo/
set "var="
set /P "var=Enter password (enter Exit to end): "
if /I "%var%" neq "exit" goto :NonCancelable
echo Terminating non cancelable...
pause
exit
关于batch-file - BATCH:阻止某人使用CTRL C或CTRL BREAK绕过我的密码脚本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36952441/