Launching Human Emulator Studio from the command line.

Launching Human Emulator Studio from the command line.

Command line options in Human Emulator Studio.
/port: “port” – indicates on which port the program is launched to receive control commands. If this parameter is not specified, the port is taken from the port.txt file in the Settings folder of the program. The port can be from 1 to 65535. For example, the /port: “7010” parameter – sets the port 7010 on which the program is running.

/script: “path to the script” – with the help of this parameter we specify which script to run in the program for execution. If the path to the script is not specified, the program is launched without executing the script. The path must be absolute, that is, for example: “C:\XWeb\Human Emulator Studio\My Scripts\1.php

/script_args: “space separated arguments” – arguments to be passed to the script being run. This parameter is used to pass any data to the script. For example, we pass: “7010 ‘1.txt’ 5″. All these values ​​will be placed in the array $argv[], that is, $argv[1] = 7010, $argv[2] =’1.txt’, and $argv[3] = 5. In this case, always $argv[0] = “path to the running script”, if the path is not specified then $argv[0] will be empty. The /port: parameter tells the whole program on which port to run, and to run the script, the port must be passed through the /script_args: parameter.

/browser_command_line: “space separated commands” – command line arguments for the Chromium browser. For example: /browser_command_line: “- disable-gpu —disable-headless-mode”. A list of available commands can be found here https://peter.sh/experiments/chromium-command-line-switches/.

/settings_folder: “path to folder” – path to the folder with settings. By default, all settings are stored in the Settings folder, which is located in the program folder. Using this parameter, you can specify a folder with settings for the program from anywhere. The path must be absolute, that is, for example: “C:\XWeb\Human Emulator Studio\Settings1

/cookies_folder: “path to the cookie folder” – set the path to the cookie folder. The path must be absolute, that is, for example: “C:\XWeb\Human Emulator Studio\7010\cookies_1

/cache_folder: “path to the cache folder” – set the folder to the cache folder. This is an obsolete parameter, since the cache folder is currently automatically placed inside the cookie folder.

/ask_port: “true” or /ask_port: “1” or /ask_port: “yes” – when starting the program, do not ask questions about switching to the next free port, if the current port is busy, then simply do not start the program.

/in_tray: “1” or /in_tray: “true” or /in_tray: “yes” – when launching, hide the program to the tray (system tray).

/hide_tray_icon: “1” or /hide_tray_icon: “true” or /hide_tray_icon: “yes” do not show the icon in the system tray (system tray).

/as_unicode: “1” or /as_unicode: “true” or /as_unicode: “yes” – the script is run in unicode format.

from version 7.0.44

/password: “psw” – to set the Password at startup setting.

/browser: “Chromium” or /browser: “Firefox” – select the browser model in which the script will be executed.

from version 7.0.47

/default_profile_path: “path” – to set the path to the default profile file.

from version 7.0.52

/decode_script_password: “password” – to pass the password when running the encoded script.

If the above parameters are not specified when starting the program from the command line, then the values ​​are taken from the program settings or take the default values.

Run the program from the command line.

How to run a program with command line parameters.

There are many ways to run with command line parameters. Consider the following:

Option 1 through a shortcut on the desktop.
Option 2 via a .bat file.

Desktop shortcut.

To do this, create a shortcut on the desktop, and then specify the command line launch parameters in the shortcut settings.

Our command line will be as follows:

/port: “7010” /script: “C:\XWeb\Human Emulator Studio\My Scripts\1.php” /script_args: “7010 ‘1.txt’ 5 “

Php script code to run from the command line:

After starting the program through this shortcut, the 1.php script will run and the following information will be displayed in the debug window:

Now, every time you run through this shortcut, we will run a script with the parameters specified in it.

Batch file

Batch file (.bat) are ordinary text files containing a set of commands and having the .bat extension. Any text editor will do for editing such a file. In this case, if you double-click on the file, then it will not open in the editor, but will execute the commands written in it.
In our case, we will register in this file the launch of the Human Emulator Studio program and pass command line parameters to it.

So, let’s run the program with the following command line /port: “7012” /script: “C:\XWeb\Human Emulator Studio\My Scripts\1.php” /script_args: “7012 ‘2332.txt’ 1123 ″. For clarity, we will run the program on port 7012 and use other arguments in this case.

Create a batch file and add the following line to it:

start “XHE Studio” “C:\XWeb\Human Emulator Studio\XWeb Human Emulator Studio.exe” /port: “7012” /script: “C:\XWeb\Human Emulator Studio\My Scripts\1.php” /script_args : “7012 ‘2332.txt’ 1123 ″.

The script will run the same one that was launched through the shortcut.

After starting the file, the program will open with the launch of the 1.php script for execution. After running the script, the following information will be displayed in the debug window:

Unlike a shortcut using a bat file, you can run several programs at once if you have a multi-threaded version of Human Emulator Studio.

In this case, our bat file will be like this:

start “XHE Studio” “C:\XWeb\Human Emulator Studio\XWeb Human Emulator Studio.exe” / port: “7012” / script: “C:\XWeb\Human Emulator Studio\My Scripts\1.php” /script_args : “7012 ‘2332.txt’ 1123 ″.
ping -n 2 localhost> nul
start “XHE Studio” “C:\XWeb\Human Emulator Studio 7011\XWeb Human Emulator Studio.exe” /port: “7011” /script: “C:\XWeb\Human Emulator Studio 7011\My Scripts\2.php” /script_args: “7011 ‘file.txt’ 123121 ″
.

Based on the results of the script, two programs will be launched and each of them will execute its own script.

You can read more about batch files and the commands they use here https://sysadmin.ru/docs/bat.