-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop_daemon.bat
More file actions
55 lines (48 loc) · 1.96 KB
/
Copy pathstop_daemon.bat
File metadata and controls
55 lines (48 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@echo off
echo ===================================================
echo Exam Lockdown Daemon - Stop Script
echo ===================================================
echo.
:: Check for administrator privileges
net session >nul 2>&1
if %errorLevel% == 0 (
echo [OK] Administrator privileges confirmed.
) else (
echo [INFO] Elevating privileges to Administrator...
powershell -Command "Start-Process cmd -ArgumentList '/c \"%~s0\"' -Verb RunAs"
exit /b
)
:: Get current directory
set SCRIPT_DIR=%~dp0
:: Find Python executable
set PYTHON_EXE=%SCRIPT_DIR%.venv\Scripts\python.exe
if not exist "%PYTHON_EXE%" (
set PYTHON_EXE=python
)
echo.
echo Stopping the ExamLockdownDaemon scheduled task...
schtasks /end /tn "ExamLockdownDaemon" >nul 2>&1
if %errorLevel% == 0 (
echo [OK] Scheduled task stopped.
) else (
echo [INFO] Scheduled task is not currently running.
)
echo.
echo Ensuring internet access is unlocked...
:: Run a small python snippet to call unlock_internet() from lockdown_daemon
"%PYTHON_EXE%" -c "from lockdown_daemon import unlock_internet; unlock_internet()"
if %errorLevel% == 0 (
echo [OK] Firewall rules cleared. Internet unlocked.
) else (
echo [WARNING] Failed to unlock internet via python. Attempting fallback...
powershell -Command "Remove-NetFirewallRule -DisplayName 'ExamSystem_BlockInternet' -ErrorAction SilentlyContinue; Remove-NetFirewallRule -DisplayName 'ExamSystem_BlockAll' -ErrorAction SilentlyContinue; Remove-NetFirewallRule -DisplayName 'ExamSystem_AllowLAN' -ErrorAction SilentlyContinue"
)
echo.
echo Forcefully terminating any remaining lockdown_daemon processes...
:: Use WMI to find and kill python processes running lockdown_daemon.py
wmic process where "name='python.exe' and commandline like '%%lockdown_daemon.py%%'" call terminate >nul 2>&1
echo.
echo ===================================================
echo Daemon Stopped and Internet Unlocked!
echo ===================================================
pause