What's new

[Guide] Using a Batch file to run the game more easily

Leba

Official Game Guide Writer
Game Volunteer
Joined
Jul 4, 2016
Messages
1,661
Reaction score
848
Points
138
Age
26
Location
Croatia
Foreword:

This guide is aimed at shortly explaining and potentially demystifying the famous batch file which is used as an alternative way of opening the game, as well as providing the reader with some fun tricks to use it for a more convenient client opening experience.

A note before we start: Opening the game this way is legal and supported. However, it doesn’t allow you to update the game or to use the settings such as the Tweak panel in the Launcher settings. You can still use tweaks, you can still update the game, however it is recommended to run the launcher after updates and for a better experience with setting the game up.


Introduction:

If you don’t know what a batch file does or how it works, I recommend reading this article.
However, to put it short, a batch file is a file which executes certain commands written inside it. What we’re trying to do here is make use of it to run a command which will start the game client, and modify the command to give us more options when doing so.
You might ask yourself though, why would I use this instead of the launcher? First of all, the whole process is a bit faster than having to wait for the launcher to load, especially when running multiple clients. In order to run the game this way, all that has to be done is opening the file (double clicking it). But more importantly, the reason why using the batch file can be better or more convenient is because of its customization.
With it, you can:
  • Select the server and gate you want to open by just specifying them as parameters, instead of having to select them in the launcher;
  • Directly log into an account, without having to type your username and password in every time;
  • Open multiple instances of the game, without having to open them one by one via the launcher;
  • Automatically set the affinity (which processor cores the clients use) without having to set it manually inside the Task Manager or by using third party tools;
  • Combine all of the above and be able to log into multiple different accounts, each with a different core set to it, all by just running one file.
Sounds quite useful, doesn’t it? Well, it is. And this guide is aimed at showing you how to make the most of using the batch file and how to make opening game clients a whole lot more convenient.

Let’s start from the beginning, how does one make a batch file?
Well, it’s quite simple. All you need to do is open a file in any text editor (such as Notepad or Notepad++), then saving the file as a Batch file, which will give it a .bat extension. It’s usually a convention to name this file “Start” or “StartGame” or something to associate the user with what it does, however you’re free to name it whatever.
O2TE1Rc.jpg


Server/region connection:

Now, if you’ve made an empty batch file and saved it, that’s good, however we’ll need write some commands in it, in order for it to do what we want.
The core command you need to use in order to run an instance of PKO is as follows:
Code:
start system\game.exe xz startgame tom:gate.piratekings.online,43

It might look scary, but it’s not. Most of the parameters and commands here are ones you won’t touch. The one which we need to talk about right away is the tom: one. This one dictates the gate and port you will connect to. It consists of an address (gated.piratekings.online) and a port (43). These two variables dictate which server you will connect to (Tortuga or Port Royal) and which region you’ll connect to (CA or CF).

The parameters for each variation of server-region can be found in the servers.xml file inside your client folder. The part we’re interested in is the following (simplified):

Code:
<ServerCollection Name="Tortuga" Key="1">
<Server Region="CF" Address="gate.piratekings.online" Port="43" Priority="10"/>
<Server Region="CA" Address="gated.piratekings.online" Port="1973" Priority="50"/>

<ServerCollection Name="Port Royal" Key="2">
<Server Region="CF" Address="gate2.piratekings.online" Port="43" Priority="10"/>
<Server Region="CA" Address="gated.piratekings.online" Port="2973" Priority="50"/>

Again, it might look scary, but it’s not. We can see that the two parameters we used in the earlier example for our first command (gated.piratekings.online and 43) belong to the Tortuga server and will connect us to the CF region.

If we’d want to connect to, for example, Port Royal and the CA region, the command would be:
Code:
 start system\game.exe xz startgame tom:gated.piratekings.online,2973
And so on, for all 4 variations…

Okay, so this allows us to connect to a certain server and region and open an instance of the game, from which we can log in as normal. But what else can be done with it?
As mentioned in the introduction, there’s several other parameters and tricks we can use in order to make the batch file even more handy.


Opening more instances of the game:

The simplest way we can make use of the batch file is to allow us to open multiple instances of the game (instead of just one) by running it. This is quite simple to do, simply copy-paste the above command, each in a new line and you will open that many game clients. For example:
Code:
start system\game.exe xz startgame tom:gate2.piratekings.online,43
start system\game.exe xz startgame tom:gate2.piratekings.online,43
start system\game.exe xz startgame tom:gate2.piratekings.online,43
the following file will open 3 game clients. Note that you can modify the tom: parameter, it doesn’t have to be the same in each line. You can log 2 accounts in Tortuga and 1 in Port Royal if you so please. Or you could log 1 client in the CF region and 1 in the CA region and compare their lagg/performance. However, you will probably mostly use this to open multiple accounts for one server/region.


Logging in with a specific account:

The command can be modified in order to let you log into a specific account (but not character!) directly, which is pretty useful, as it skips the whole username/password selection.

All we have to do is add 2 parameters to the command we’ve shown earlier, like so:
Code:
start system\game.exe xz startgame tom:gated.piratekings.online,43,LOGIN,PASSWORD
with LOGIN and PASSWORD being the username and password of the account you want to log into.

The following command will log into the account with the username MainAccount and password123 password:
Code:
start system\game.exe xz startgame tom:gated.piratekings.online,43,MainAccount,password123

Of course, you can combine this with the previously given tip, and log multiple accounts in at once.
For example, the following command will open 2 game clients, and immediately log into 2 accounts, (MainAccount – password123) and (BufferAccount – password1234):
Code:
start system\game.exe xz startgame tom:gated.piratekings.online,43,MainAccount,password123
start system\game.exe xz startgame tom:gated.piratekings.online,43,BufferAccount,password1234

NOTE: if you choose to include your username and password in a batch file, DO NOT share it with anyone, as they will simply be able to open it and see your login information. Stay vigilant!


Setting the affinity of each game client:

The last tip given in this guide will be the ability to set the affinity of the client(s) you open with the Batch file. What affinity does, to put it simple, is it assigns specific processor cores to the process (game client). Normally, opening the game this way makes the PC assign all cores to it, which is a waste, as the game typically only requires resources from one to work properly.
In the context of the game, it is usually a good idea to have each client on a different core, as it makes the gameplay more smooth and makes the unfocused window less laggy. This is useful for when you’re i.e. leveling characters and you want their auto follow to be smooth.

The way to do this is to add the /AFFINITY parameter to the command.

The following command will open a game client and will assign the first core (usually annotated as CPU 0 in the task manager) to it:
Code:
 start /AFFINITY 1 "" system\game.exe xz startgame tom:gated.piratekings.online,43

By modifying the parameter (number) after the /AFFINITY parameter, you’re able to select different cores – as many as your processor has. (With modern PCs, this is usually 4, 8, 16 or 32).

The following table is used to show which core will be assigned to the process, based on the number that’s stated after /AFFINITY.
1 = 1
2 = 2
3 = 4
4 = 8
5 = 10
6 = 20
7 = 40
8 = 80
9 = 100
10 = 200
11 = 400
12 = 800
13 = 1000
14 = 2000
15 = 4000
16 = 8000
(Credits to SPIRIT from Mordo.ru for this table)

Note: this table states 16 cores and their values, but it can be used on 4-8 core PCs as well. The values for the second 16 cores on 32 core PCs have not been included here.


Combining it all:

If it’s not already clear, all of these different parameters and tricks can be combined together, in order to make opening clients and logging into the game just a few clicks away.

So let’s make a more complicated command to see how we can utilize all of these parameters.
Let’s say we want to have a command which we’ll run for when we want to level disciples – that would require a main character, a buffer and 4 accounts for the disciples. It’s usually a good idea to assign a different core to each account, so we might as well include that instead of having to set it manually.

Let’s say our accounts are as follows:
  • MainAccount – password123
  • BufferAccount – password1234
  • DiscipleAccount1 – password321
  • DiscipleAccount2 – password321
  • DiscipleAccount3 – password321
  • DiscipleAccount4 – password321

The aforementioned feat (logging into all 6 of them at once and assigning a different core to each of them) can be achieved with a batch file that has the following content:
Code:
start /AFFINITY 1 "" system\game.exe xz startgame tom:gated.piratekings.online,43,MainAccount,password123
start /AFFINITY 2 "" system\game.exe xz startgame tom:gated.piratekings.online,43,BufferAccount,password1234
start /AFFINITY 4 "" system\game.exe xz startgame tom:gated.piratekings.online,43,DiscipleAccount1,password321
start /AFFINITY 8 "" system\game.exe xz startgame tom:gated.piratekings.online,43,DiscipleAccount2,password321
start /AFFINITY 10 "" system\game.exe xz startgame tom:gated.piratekings.online,43,DiscipleAccount3,password321
start /AFFINITY 20 "" system\game.exe xz startgame tom:gated.piratekings.online,43,DiscipleAccount4,password321
Note: on PCs with 4 (or less) cores, you would simply repeat the pattern when opening more accounts than your PC has cores. In the example right above, this would mean repeating one of the four parameters for the first 4 cores (1, 2, 4, 8) instead of using the 10, 20 parameters.

The same can be done for logging in just a main character and a buffer as well, or logging in fortune tree choppers and so on. The sky is the limit.

Concluding notes:

I hope this guide’s been useful and people who weren’t aware of the possibilities of using batch files are able to utilize them, in order to make opening accounts and game clients a more convenient process.

There are a few things worth stating though:
  • You can make as many of these files as you want, all with different content. You can have one which will open your main account, titled “StartMain”, for example. Or one which will open your main and your buffer account, titled “StartMainBuffer”, or the last command written here which opens a full disciple leveling setup, and so on and so forth. Be creative and make good use of it.
  • As stated in the beginning of the guide, use these files at your own discretion. Using the Launcher is still more user-friendly and allows for more setting up, so don’t forget to update your client or to use it to set up tweaks or settings more easily.
  • As mentioned before, sharing these files is not problematic. They can be run by anyone and everyone, but make sure not to forget that if you make use of the login/password parameter, you should either not share the file or remove any account information from them.
  • Another reminder, in case you want to use these commands here or copy-paste them, remember to edit the tom: parameter mentioned at the beginning to match your server and your preferred region.
  • Lastly, these files are completely legal, however, should you encounter some issue or should something not work as intended (for example game not updating, tweaks not working, etc.), it’s not likely you’ll get direct support for it. If something goes wrong, make sure to open the game using the Launcher instead.
 
Last edited:
this doesnt work for meit says cannot find system\game.exe but START C:\"Program Files (x86)\Pirate King Online"\PirateKingOnlineLauncher.exe works but it redownloads all the resources again right after the clients open up
 
this doesnt work for meit says cannot find system\game.exe but START C:\"Program Files (x86)\Pirate King Online"\PirateKingOnlineLauncher.exe works but it redownloads all the resources again right after the clients open up
There's 2 reasons why I think this might be happening:
  1. You've made some kind of error when writing the command(s);
  2. You're running the batch file outside of PKO's root folder.
I didn't note this in the guide, but in order to use the batch file, it has to either be inside the PKO folder, or you have to create a shortcut, if you want to put it inside another folder, on your desktop and etc. There's probably some shenanigans you can do with absolute and relative paths inside the command itself, but it's just easier to either run it inside the folder or to make a shortcut.
 
Thanks for the guide! This will save me some time!
 
Back
Top