[Windows7+] Smart launcher script

Post Reply
User avatar
Stoikva
Known Venturer
Posts: 130
Joined: Mon Dec 25, 2017 6:54 am
Location: England

[Windows7+] Smart launcher script

Post by Stoikva » Fri Jan 26, 2018 6:02 am

This is intended as a last resort attempt too diagnose and run the client

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
Last edited by Stoikva on Fri Jan 26, 2018 7:32 am, edited 1 time in total.
Your eyes drawn to irregularities and then the video

User avatar
Troll n roll
Premium Donator
Posts: 1857
Joined: Thu Jun 27, 2013 10:05 pm
Location: ❄ My Igloo ❄

Re: [Windows7+] Smart launcher script

Post by Troll n roll » Fri Jan 26, 2018 6:29 am

My .jar works fine, thanks though.
Image
Adam the lion wrote:If you are making super pots for profit on an rsps, you really need to re-evaluate your life.

Simon
Honor Player
Posts: 5815
Joined: Thu Apr 11, 2013 12:03 am

Re: [Windows7+] Smart launcher script

Post by Simon » Fri Jan 26, 2018 8:44 am

I tried to run this on my Mac and I received the error "unable to load pkhonor.exe"

I think it's an issue with my power supply. I'm going to try flipping the circuit breaker in my basement. Hopefully my client will load after the full restart is completed.
Image
Image
Image

User avatar
Jon
Helper
Posts: 4626
Joined: Mon Jun 10, 2013 6:31 pm
Location: PkHonor
Contact:

Re: [Windows7+] Smart launcher script

Post by Jon » Fri Jan 26, 2018 4:17 pm

Color x wrote:My .jar works fine, thanks though.
^
Image

User avatar
Stoikva
Known Venturer
Posts: 130
Joined: Mon Dec 25, 2017 6:54 am
Location: England

Re: [Windows7+] Smart launcher script

Post by Stoikva » Fri Jan 26, 2018 8:49 pm

Yes if you can run the client with no issues then this post isn't for you (: pretty much of someone is doing something wrong this should work and inform them of why it will not launch too providing a log too which may help provide better info as too why
Your eyes drawn to irregularities and then the video

User avatar
Slap a ho
Champion
Posts: 1664
Joined: Mon Nov 10, 2014 11:26 am

Re: [Windows7+] Smart launcher script

Post by Slap a ho » Fri Jan 26, 2018 9:52 pm

Don’t think it reads through the typos, does it?
Image

User avatar
Stoikva
Known Venturer
Posts: 130
Joined: Mon Dec 25, 2017 6:54 am
Location: England

Re: [Windows7+] Smart launcher script

Post by Stoikva » Fri Jan 26, 2018 10:24 pm

Slap a ho wrote:Don’t think it reads through the typos, does it?
typos? People don't name their pkhonor.jar themselves so it's unlikely, however i will be adding support for finding the last modified one, as redownloading may go to PKHonor (2).jar and then they may delete pkhonor.jar later on aswell.

also planning on preforming manual searches for any java installation if the java/javaw environment variables are not set.
Your eyes drawn to irregularities and then the video

Post Reply