-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPeacockLauncher.bat
51 lines (45 loc) · 1.31 KB
/
PeacockLauncher.bat
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
@echo off
setlocal enabledelayedexpansion
set patcher="PeacockPatcher.exe"
set server="Start Server.cmd"
set launcher=Launcher.exe
set serverPort=80
set peacockLocation=%1
set hitmanLocation=%~dp0
cd %peacockLocation%
call :reLaunch %patcher%
call :relaunch %server% -s %serverPort%
cd %hitmanLocation%
start %launcher%
endlocal
EXIT /B
:reLaunch
if "%2"=="-s" (
if "%3"=="" (
echo "ERR: Use -s tag with the following syntax:"
echo ":relaunch [EXE] -s [PORT]"
EXIT /B 0
)
REM Find the PID of the process using port %3 and kill
for /f "tokens=2,5" %%a in ('netstat -ano ^| findstr :%3') do (
if "%%a"=="0.0.0.0:%3" (
echo "Process found on port %3 (PID: %%b)..."
taskkill /PID %%b /F
echo "Process terminated."
)
)
) else (
REM Check if process is already running
echo "Checking for process: %1"
tasklist /FI "IMAGENAME eq %1" 2>NUL | find /I /N "%1">NUL
REM Kill the process
if "!ERRORLEVEL!"=="0" (
echo "Process found, attempting to kill: %1"
taskkill /F /IM %1
) else (
echo "Process not found: %1"
)
)
echo "Launching %1..."
start "Peacock Server" %1
EXIT /B 0