The stackregent.exe command line
stackregent.exe is the panel itself and its toolbox. Run it on the server to call the API locally, get back in after a lockout, change ports, set the license and run panel tasks.
Where stackregent.exe is and how to run it#
stackregent.exe is in the bin folder of the installation, normally:
C:\Program Files\StackRegent\bin\stackregent.exeRun it in a command prompt or PowerShell opened with Run as administrator on the server. The folder is not on the PATH, so change into it or call it by full path:
cd 'C:\Program Files\StackRegent\bin'
.\stackregent versionMost commands read the panel configuration from the installation folder and open the panel database directly, so they work even when the web service is stopped. The exceptions are api, which talks to the running panel over HTTPS, and the task commands (website-apply, run-task, site-run), which need the StackRegentTask service to run the task.
Exit codes#
| Code | Meaning |
|---|---|
| 0 | The command finished. For task commands, check the last line of the output: it is success or failure. |
| 1 | The command failed. The reason is printed after error:. For api, an HTTP status of 400 or above also gives 1, after the answer is printed. |
| 2 | The command or its options were not understood; the usage line is printed. |
stackregent.exe command line reference#
| Command | What it does |
|---|---|
stackregent version | Prints the version. --version and -v do the same. |
stackregent api METHOD /api/PATH [JSON or @file] | Calls the REST API as the main administrator and prints the answer |
stackregent admin-password [-login NAME] | Sets a new random password for an administrator and prints it |
stackregent admin-add LOGIN | Adds a support administrator and prints its password once |
stackregent admin-remove LOGIN | Removes an administrator (not the main one) |
stackregent sessions-purge | Logs everyone out of the panel |
stackregent ip-access-reset | Lets administrators log in from any address again |
stackregent firewall-reset | Turns off Panic Mode and access limits and disables your own firewall rules |
stackregent panel-url-reset | Clears Customize Panel URL |
stackregent panel-port HTTPS [HTTP] | Moves the panel to other ports |
stackregent license-set [KEY] | Saves a license key and checks it |
stackregent license-check | Checks the license now |
stackregent website-apply DOMAIN | Applies one website's hosting settings again |
stackregent run-task KIND [JSON or @file] | Queues a panel task, waits for it and prints its log |
stackregent site-run ID PROGRAM [ARGS...] | Runs a program as a website's subscription user |
stackregent dkim-verify FILE [DNS-SERVER] | Checks the DKIM signatures of a saved message |
stackregent defender-exclude | Adds Microsoft Defender exclusions for the panel's database folders |
stackregent migration-agent [options] | On a Plesk for Windows server: lets a StackRegent server migrate from it |
api: call the REST API on the server#
stackregent api GET /api/subscriptions
stackregent api GET "/api/subscriptions?q=example.com"
stackregent api POST /api/subscriptions/12/status '{"status":"suspended"}'
stackregent api PUT /api/subscriptions/12/plan @plan.json
stackregent api DELETE /api/domains/31The method is GET, POST, PUT or DELETE, and the path must start with /api/. For POST and PUT, add the JSON body as the third argument, or @file.json to read it from a file. Use a file from Windows PowerShell 5.1, which mangles quotes inside arguments passed to programs; a byte order mark at the start of the file is ignored.
For each call, the command creates a key for the main administrator that works only from 127.0.0.1 and ::1, lasts one minute and is deleted after the call. It connects to https://127.0.0.1 on the panel's configured HTTPS port, so it keeps working after panel-port and with a self-signed certificate. JSON answers are printed indented, and a call may take up to 10 minutes. The endpoints and fields are the same as over the network; see the REST API reference.
admin-password: reset an administrator's password#
stackregent admin-password
stackregent admin-password -login support1Without -login, it resets admin. It prints the new password, turns off two-step sign-in for that administrator, closes their sessions and clears their failed-login counter. Turn two-step sign-in on again under Profile after logging in.
admin-add and admin-remove#
stackregent admin-add support1
stackregent admin-remove support1admin-add creates a support administrator with a random 16-character password and prints it once. The login is stored in lower case and must not exist already. admin-remove deletes the administrator and their sessions; the main administrator cannot be removed.
Recovery after a lockout#
These undo a lockout without a browser:
sessions-purgecloses every panel session and prints how many were closed.ip-access-resetremoves the administrator IP access restriction after it locks you out.firewall-resetturns off Panic Mode and access limits and disables your own firewall rules.panel-url-resetclears Customize Panel URL, so the panel answers on every host name again.
panel-port: move the panel to other ports#
stackregent panel-port 8443
stackregent panel-port 8443 8080Both ports must be between 1024 and 65535, different from each other, and not one of the ports used by websites (80, 443), website preview (9444), FTP (21), mail (25), DNS (53), MariaDB (3306), SQL Server (1433) or the panel database. The command checks that the ports are free, saves them, replaces the StackRegent panel rules in Windows Firewall and restarts the panel service. Without the second argument the HTTP port stays as it is. Open the new port in any provider firewall too, and update the port in a custom panel URL if you use one.
license-set and license-check#
stackregent license-set SR-XXXXX-XXXXX-XXXXX-XXXXX
$env:STACKREGENT_LICENSE_KEY = 'SR-XXXXX-XXXXX-XXXXX-XXXXX'
stackregent license-set
Remove-Item Env:STACKREGENT_LICENSE_KEY
stackregent license-checklicense-set saves the key and checks it with the license server at once. If you leave out the argument, the key is read from STACKREGENT_LICENSE_KEY, which keeps it out of command histories and transcripts; the installer uses it that way. license-check checks the saved key again. Both print a line such as Licence: licensed. ..., where the state is licensed, grace or restricted, followed by the license server's message. They wait up to 30 seconds for the license server.
website-apply: apply a website's settings again#
stackregent website-apply example.comQueues the task that writes one website's IIS and hosting settings again, waits up to five minutes, and prints the task log followed by success or failure. Use it after something was changed by hand in IIS Manager, or to see exactly where a website's configuration fails.
run-task: queue a panel task#
stackregent run-task update.check
stackregent run-task component.install @component.jsonQueues a task of the given kind with optional JSON parameters (inline or from @file), waits up to 10 minutes and prints the log followed by success or failure. The installer uses it to set up hosting components, with a file such as:
{"id":"git","key":""}Component IDs are listed under Tools & Settings › Server Components and on the install script page. Other task kinds take parameters that are internal to the panel; prefer the REST API for anything it covers.
site-run: run a program as the subscription user#
stackregent site-run 31 whoamiID is the domain's ID (from GET /api/domains). The task service runs the program as the Windows user of that website's subscription, so it sees exactly the permissions the website has. The output and success or failure are printed; the command waits up to 15 minutes.
dkim-verify: check a message's DKIM signatures#
stackregent dkim-verify C:\temp\message.eml
stackregent dkim-verify C:\temp\message.eml 1.1.1.1Checks the DKIM signatures in a saved message, looking up the public keys in DNS, optionally through the DNS server you name.
defender-exclude#
Adds Microsoft Defender exclusions for the panel's database folders and prints the result. Run it again if a policy removed them.
Migration agent options#
migration-agent runs on a Plesk for Windows server, from a copy of stackregent.exe taken from the bin folder of the StackRegent package, so that a StackRegent server can migrate accounts from it over HTTPS.
stackregent migration-agent --allow 203.0.113.50
stackregent migration-agent --allow 203.0.113.50,198.51.100.0/24 --port 9445 --key MY-FIXED-KEY| Option | Default | Meaning |
|---|---|---|
--allow | none | IP addresses or networks of the new server, comma-separated |
--port | 9445 | HTTPS port the agent listens on |
--key | a new key each start | A fixed key to keep across restarts |
--config | none | Runs the background agent from its settings file (used by the StackRegent Migrator extension for Plesk) |
The agent uses a self-signed certificate and prints its SHA-256 fingerprint, so you can compare it when the new server connects. It runs until you press Ctrl+C. The Plesk extension controls its background agent with migration-agent-ctl. See the migration chapter of the administrator guide.
Commands used by the installer and the services#
These exist for the installer, the Windows services and support. You normally do not run them yourself; to repair or upgrade an installation, run the installer again.
| Command | Used by | What it does |
|---|---|---|
web | Service StackRegent | Runs the panel web server |
task | Service StackRegentTask | Runs the task runner and scheduler |
guard | Service StackRegentGuard | Runs the brute-force guard |
spamd | Service StackRegentSpamd (SpamAssassin component) | Runs the spam filter service |
setup [options] | install.ps1 | First-time configuration (see below) |
migrate | install.ps1 | Updates the panel database schema |
service-install, service-remove | install.ps1 | Registers or removes the Windows services |
service-restart NAME | Panel tasks | Restarts one service after a short pause |
mail-pickup | MailEnable | Signs outgoing mail with DKIM |
user-op, monitor-test, git-selftest, safefs-test | Panel internals and support | Internal operations and self-tests |
setup options#
setup writes the configuration, creates the panel database schema and, on the first run only, creates the admin account and prints ADMIN_LOGIN=admin and ADMIN_PASSWORD=.... On later runs it leaves the password alone.
| Option | Default | Meaning |
|---|---|---|
--dir | The folder above bin | Installation folder |
--db-pass | STACKREGENT_DB_PASS | Password of the panel database user (required) |
--db-port | 8306 | Panel database port |
--admin-email | empty | Administrator email address |
--hostname | empty | Panel host name |
--https-port | 9443 | Panel HTTPS port |
--http-port | 9080 | Panel HTTP port, which redirects to HTTPS |
Use the install script rather than calling setup yourself; the script also prepares the database, services and firewall.
Frequently asked questions
Where is stackregent.exe installed?
In the bin folder of the installation, normally C:\Program Files\StackRegent\bin. Run it from an elevated command prompt or PowerShell on the server.
How do I reset the StackRegent admin password from the command line?
Run stackregent admin-password in an elevated prompt on the server. It prints a new password for admin, turns off two-step sign-in for that account and closes its sessions. Add -login NAME for another administrator.
I locked myself out with IP access restriction. How do I get back in?
Run stackregent ip-access-reset on the server. If the firewall is the problem, stackregent firewall-reset turns off Panic Mode and access limits; if a custom panel URL is, stackregent panel-url-reset clears it.
How do I change the StackRegent panel port?
Run stackregent panel-port with the new HTTPS port and optionally the HTTP port, for example stackregent panel-port 8443 8080. It checks the ports, updates Windows Firewall and restarts the panel.
Does stackregent api need an API key?
No. It makes a one-minute key for the main administrator that works only from the server itself, and deletes it after the call.
Why does stackregent api fail to connect?
It calls the running panel on 127.0.0.1. Check that the StackRegent service is running, for example in the Service Monitor or with Get-Service StackRegent.
How do I pass JSON to stackregent from PowerShell 5.1?
Save the JSON in a file and pass @file.json. Windows PowerShell 5.1 changes quotes inside arguments, which breaks inline JSON.