To use, copy the code from below or from the link into notepad
Save as PKLauncher.bat and make sure to have file type set to all files (*)
(https://www.irccloud.com/pastebin/cUX4J ... uncher.bat)
Code: Select all
::
::
:: PKHonor advanced launcher for departertrons
::
:: > Requests admin permision
:: > Runs anyway if admin can't be requests
:: > Checks if java is installed
:: > Attempts to run the .jars even if java isn't found
:: > Opens up java or client download pages if needed
::
:: Feedback thread: https://forums.pkhonor.net/viewtopic.php?f=49&t=70568
:: Update link: https://www.irccloud.com/pastebin/cUX4Jd2b/PKLauncher.bat
:: Version: v0.1
::
::
@echo off
cls
title=PKHonor client launcher
::set path
set log_path="%cd%\%~n0_log.txt"
::display and log information
call :log ----------------%date% PKHonor start
::Write some information from sys32 to none existant file
::Only admin can perform this and the action is benign (does nothing)
::except what it can do is raise the %errorlevel% state to indicate an error
::this means we can know if the script is ran as admin or not
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
::error level '0' means no errors, we are admin
if '%errorlevel%' EQU '0' (goto launchClient)
::if we are not admin then this code below will run
::This writes a visual basic script that will run this script as admin
::%~s0 is the the variable that outputs the location of this current script
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\RequestAdmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\RequestAdmin.vbs"
::This runs the vb script and exit since we are starting again as admin
"%temp%\RequestAdmin.vbs"
::if we have failed to create the admin prompt script
::user is incapable of having admin priveledges
::this will make the script
if '%errorlevel%' EQU '5' (
call :log Cannot launch admin prompt
goto notAdmin
)
if '%errorlevel%' EQU '9059' (
call :log Cannot find admin prompt
goto notAdmin
)
exit /B
::If we are admin we come here and skip the admin prompt
:launchClient
::clear up the temperary admin prompt script if it exists
IF EXIST "%temp%\RequestAdmin.vbs" (erase "%temp%\RequestAdmin.vbs")
pushd "%CD%"
CD /D "%~dp0"
set log_path="%cd%\%~n0_log.txt"
:notAdmin
::Now we begin attempting to launch pkhonor
::First check if java can be located
set javaModule=NOJAVA
java -version >nul 2>&1 && (
set javaModule=java
call :log java found
)
javaw -version >nul 2>&1 && (
set javaModule=javaw
call :log javaw found
)
::Now we search for pkhonor.jar
set PKClient=NOCLIENT
if exist "%userprofile%\Desktop\PKHonor.jar" (
set PKClient="%userprofile%\Desktop\PKHonor.jar"
)
if exist "%userprofile%\Downloads\PKHonor.jar" (
set PKClient="%userprofile%\Downloads\PKHonor.jar"
)
if exist "%cd%\PKHonor.jar" (
set PKClient="%cd%\PKHonor.jar"
)
if exist %PKClient% (
call :log PKHonor.jar found at %PKClient%
call :log Launching client...
if "%javaModule%" NEQ "NOJAVA" (
Start %javaModule% -Xmx1000m -jar %PKClient%
) else (
start %PKClient%
if '%errorlevel%' EQU '9059' (
call :log No java found, please download at https://java.com/en/download/
start "https://java.com/en/download/"
pause
)
if '%errorlevel%' EQU '5' (
call :log Unable to run java, please download at https://java.com/en/download/
start "https://java.com/en/download/"
pause
)
)
) else if exist "%userprofile%\Documents\My Games\PkHonor" (
call :log No jar files where found but desktop client exists, attempting to run...
cd "%userprofile%\Documents\My Games\PkHonor"
start "Play PkHonor.bat"
) else (
call :log Cannot find PKHonor.jar please download at https://www.pkhonor.net/playnow.php
start "https://www.pkhonor.net/playnow.php"
pause
)
exit /B
:log
echo %*>>"%log_path%"
echo PKHonor^> %*
EXIT /B 0