锁定脚本批处理文件

时间:2014-05-09 15:16:29

标签: batch-file

好的,所以我有一个锁定我的电脑的锁定脚本,但使用alt + tab可以解决这个问题。有办法阻止这个吗?此外,输入任何内容并按下输入也会绕过它。

代码使用2个窗口,一个用于在窗口关闭时保持窗口打开

@echo off
powershell -command "& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }"
tskill explorer
tskill explorer
:a
start /w Lock.bat
goto a

另一个是实际的锁定脚本:

@echo off
mode 35,10
cls
color a
title Locked by %username%
echo What is the password?
set /p password=
if %password%==password goto end
goto fail

:end
start explorer
exit

:fail
exit

有没有办法阻止这些发生?

编辑

我使用

解决了空白问题
If [%password%]==[] goto fail

1 个答案:

答案 0 :(得分:1)

虽然我不知道如何通过上面概述的行为来阻止探索者进程的产生,但这里有一个杀死wa

主要剧本:

@echo off
powershell -command "& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }"
start /min kill_switch.bat
:a
start /w Lock.bat
goto a

Lock.bat:

@echo off
mode 35,10
cls
color a
title Locked by %username%
echo What is the password?
set /p password=
if %password%==password goto end
goto fail

:end
echo "start explorer">"%TEMP%\startex.trace"
exit

:fail
exit

kill_switch.bat:

@echo off

if exist "%TEMP%\startex.trace" del /q "%TEMP%\startex.trace"

:KILL_SWITCH
for /f "skip=2 tokens=2 delims= " %%a in ('tasklist /FI "IMAGENAME eq explorer.exe"') do (
    echo INFO: Killing PID %%a
    taskkill /PID %%a /F
)

timeout /t 5 >nul
if not exist "%TEMP%\startex.trace" (
    goto KILL_SWITCH
) else (
    del /q "%TEMP%\startex.trace"
)