-
-
Notifications
You must be signed in to change notification settings - Fork 88
Examples & Recipes
- Introduction
- Note on
--paramsUsage - Run a Node.js / Express App as a Service
- Run a Python Script as a Service
- Run a Go App as a Service
- Run a Java JAR as a Service
- Run a Rust App as a Service
- Run a C/C++ Compiled App Script as a Service
- Run a PHP App as a Service
- Run a Ruby App as a Service
- Run a Haskell App as a Service
- Run a .NET App as a Service
- Run a PowerShell Script as a Service
- Run a Batch File as a Service
- Run an AutoHotkey Script as a Service
- Run a VBScript as a Service
- Run a WSL Bash Script as a Service
- Run a Julia Script as a Service
- Run a Dart Server or Script as a Service
- Run an R Script as a Service
- Run a Lua Script as a Service
- Run a Perl Script as a Service
- Run an OCaml Script or App as a Service
- Run a Zig App as a Service
- Run a Pascal/Delphi App as a Service
- Run a Fortran App as a Service
- Run an Elixir Script as a Service
- Run an Erlang Script as a Service
- Tips & Notes
- See Also
Services can be installed and configured easily through the Servy Desktop App or the PowerShell module, but this page focuses on real-world examples using the Servy CLI for automation, scripting, and CI/CD scenarios.
Once installed, the CLI executable is available at:
C:\Program Files\Servy\servy-cli.exe
Note: If the value of --params in install command includes arguments that start with --, use an equals sign (=) to prevent parsing issues. Example: --params="--mode=production --port=7008" Without the equals sign, the CLI might interpret --mode or --port as its own options instead of part of the service parameters.
servy-cli install `
--name="MyNodeApp" `
--description="Node.js Express API" `
--path="C:\Program Files\nodejs\node.exe" `
--params="C:\apps\myapp\server.js" `
--startupDir="C:\apps\myapp" `
--startupType="Automatic"servy-cli install `
--name="MyPythonJob" `
--description="Python background job" `
--path="C:\Python311\python.exe" `
--params="C:\apps\scripts\job.py" `
--startupDir="C:\apps\scripts" `
--startupType="Automatic"servy-cli install `
--name="MyGoService" `
--description="Go background service" `
--path="C:\apps\my-go-app\my-go-app.exe" `
--params="--port=8080 --mode=worker" `
--startupDir="C:\apps\my-go-app" `
--startupType="Automatic"servy-cli install `
--name="MyJavaService" `
--description="Java Spring Boot App" `
--path="C:\Program Files\Java\jdk-21\bin\java.exe" `
--params="-jar C:\apps\springboot\app.jar" `
--startupDir="C:\apps\springboot" `
--startupType="Automatic"servy-cli install `
--name="MyRustService" `
--description="Rust background service" `
--path="C:\apps\rustsvc\rust_svc.exe" `
--startupDir="C:\apps\rustsvc" `
--startupType="Automatic"servy-cli install `
--name="MyCppService" `
--description="C++ Application" `
--path="C:\apps\cpp-service\service.exe" `
--startupDir="C:\apps\cpp-service" `
--startupType="Automatic"servy-cli install `
--name="MyPHPWorker" `
--description="PHP queue worker" `
--path="C:\php\php.exe" `
--params="C:\apps\worker\queue-worker.php" `
--startupDir="C:\apps\worker" `
--startupType="Automatic"servy-cli install `
--name="MyRubyApp" `
--description="Ruby background app" `
--path="C:\Ruby32\bin\ruby.exe" `
--params="C:\apps\rubyapp\app.rb" `
--startupDir="C:\apps\rubyapp" `
--startupType="Automatic"servy-cli install `
--name="MyHaskellService" `
--description="Haskell background worker" `
--path="C:\apps\haskell\myapp.exe" `
--startupDir="C:\apps\haskell" `
--startupType="Automatic"servy-cli install `
--name="MyDotNetApp" `
--description=".NET Worker Service" `
--path="C:\apps\dotnetapp\MyApp.exe" `
--startupDir="C:\apps\dotnetapp" `
--startupType="Automatic"Or, if using dotnet runtime with a DLL:
servy-cli install `
--name="MyDotNetApp" `
--description=".NET Worker Service" `
--path="C:\Program Files\dotnet\dotnet.exe" `
--params="C:\apps\dotnetapp\app.dll" `
--startupDir="C:\apps\dotnetapp" `
--startupType="Automatic"servy-cli install `
--name="MyPowerShellScript" `
--description="Batch automation job" `
--path="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" `
--params='-File \"C:\scripts\script\my script.ps1\"' `
--startupDir="C:\scripts\script" `
--startupType="Automatic" servy-cli install `
--name="MyBatchScript" `
--description="Batch automation job" `
--path="C:\Windows\System32\cmd.exe" `
--params="/c C:\scripts\backup-job.bat" `
--startupDir="C:\scripts" `
--startupType="Automatic"servy-cli install `
--name="MyAutoHotkeyService" `
--description="Batch automation job" `
--path="C:\Program Files\AutoHotkey\v2\AutoHotkey.exe" `
--params="C:\scripts\service.ahk" `
--startupDir="C:\scripts" `
--startupType="Automatic"You can find a sample AutoHotkey script here.
Running an AutoHotkey script as a service gives you clear advantages, but also some limits, and it really depends on what your script does.
When a script runs as a service, it can start immediately when Windows starts. It does not have to wait for a user to log in, so it is great for scripts that should always be running in the background, even on a machine that stays logged out most of the time. This is helpful for automation tasks that do not depend on the desktop, such as file monitoring, network checks, background cleanup or anything that works quietly without talking to the user.
The main limitation is that Windows services cannot normally interact with the desktop. This means hotkeys, mouse actions, sending keystrokes and interacting with windows on the screen will not work when the script runs as a service. These kinds of features require a user session, so they only work if the script runs after login, for example through the Startup folder or the Task Scheduler with "run at logon".
A service is useful when you want something to run early and silently with no user involved. But if your AutoHotkey script needs to press keys, respond to hotkeys, show windows or control applications on the screen, then running it as a service will not work well. In that case, starting it after login is the right option.
servy-cli install `
--name="MyVBScript" `
--description="VBScript automation job" `
--path="C:\Windows\System32\cscript.exe" `
--params="C:\scripts\tasks\job.vbs" `
--startupDir="C:\scripts\tasks" `
--startupType="Automatic"If you prefer wscript.exe (windowed, but still works as a service):
servy-cli install `
--name="MyVBScript" `
--description="VBScript automation job" `
--path="C:\Windows\System32\wscript.exe" `
--params="C:\scripts\tasks\job.vbs" `
--startupDir="C:\scripts\tasks" `
--startupType="Automatic"servy-cli install `
--name="MyWSLScript" `
--description="WSL Bash script service" `
--path="C:\Windows\System32\wsl.exe" `
--params="bash /home/user/scripts/run.sh" `
--startupDir="C:\Windows\System32" `
--startupType="Automatic"If you need a specific distribution:
servy-cli install `
--name="MyUbuntuWSLService" `
--description="WSL Ubuntu service job" `
--path="C:\Windows\System32\wsl.exe" `
--params="-d Ubuntu bash /home/user/app/start.sh" `
--startupDir="C:\Windows\System32" `
--startupType="Automatic"(Used for ML jobs, analytics, long-running computation workers)
servy-cli install `
--name="MyJuliaService" `
--description="Julia analytics worker" `
--path="C:\Julia-1.10\bin\julia.exe" `
--params="C:\apps\julia\worker.jl" `
--startupDir="C:\apps\julia" `
--startupType="Automatic"(Shelf web services, background workers, API servers, etc.)
servy-cli install `
--name="MyDartService" `
--description="Dart backend service" `
--path="C:\tools\dart-sdk\bin\dart.exe" `
--params="C:\apps\dart\server.dart" `
--startupDir="C:\apps\dart" `
--startupType="Automatic"servy-cli install `
--name="MyRService" `
--description="R background job" `
--path="C:\Program Files\R\R-4.4.1\bin\Rscript.exe" `
--params="C:\apps\r\job.R" `
--startupDir="C:\apps\r" `
--startupType="Automatic"servy-cli install `
--name="MyLuaService" `
--description="Lua automation script" `
--path="C:\Lua\5.4\lua.exe" `
--params="C:\apps\lua\script.lua" `
--startupDir="C:\apps\lua" `
--startupType="Automatic"servy-cli install `
--name="MyPerlService" `
--description="Perl Script" `
--path="C:\Perl64\bin\perl.exe" `
--params="C:\apps\perl-task\task.pl" `
--startupDir="C:\apps\perl-task" `
--startupType="Automatic"servy-cli install `
--name="MyOCamlService" `
--description="OCaml background worker" `
--path="C:\OCaml\bin\ocaml.exe" `
--params="C:\apps\ocaml\worker.ml" `
--startupDir="C:\apps\ocaml" `
--startupType="Automatic"If you compiled your OCaml code to a native executable (e.g., worker.exe), you can skip ocaml.exe and set --path directly to the executable:
servy-cli install `
--name="MyOCamlService" `
--description="OCaml compiled worker" `
--path="C:\apps\ocaml\worker.exe" `
--startupDir="C:\apps\ocaml" `
--startupType="Automatic"This way, you can run either scripts or compiled OCaml apps as Windows services using Servy.
servy-cli install `
--name="MyZigService" `
--description="Zig background worker" `
--path="C:\apps\zig\myapp.exe" `
--startupDir="C:\apps\zig" `
--startupType="Automatic"servy-cli install `
--name="MyPascalService" `
--description="Delphi background app" `
--path="C:\apps\pascal\worker.exe" `
--startupDir="C:\apps\pascal" `
--startupType="Automatic"servy-cli install `
--name="MyFortranService" `
--description="Fortran computational service" `
--path="C:\apps\fortran\worker.exe" `
--startupDir="C:\apps\fortran" `
--startupType="Automatic"servy-cli install `
--name="MyElixirService" `
--description="Elixir background worker" `
--path="C:\Program Files\Elixir\bin\elixir.bat" `
--params="C:\apps\elixir\worker.exs" `
--startupDir="C:\apps\elixir" `
--startupType="Automatic"Notes:
- For Elixir, you can point
--paramsto any.exsscript or mix task.
servy-cli install `
--name="MyErlangService" `
--description="Erlang background worker" `
--path="C:\Program Files\erl-25.3\bin\erl.exe" `
--params="-noshell -s my_app start -s init stop" `
--startupDir="C:\apps\erlang" `
--startupType="Automatic"Notes:
- For Erlang, the
-sparameters start the desired module and function. Adjust according to your OTP app.
Tip: You can view and manage all installed services visually using Servy Manager, or automate deployments via Servy CLI.
Copyright © Akram El Assas. All rights reserved.
- Home
- Overview
- Installation Guide
- Advanced Configuration
- Usage
- Servy Desktop App
- Servy Manager
- Servy CLI
- PowerShell Module
- Examples & Recipes
- Logging & Log Rotation
- Health Monitoring & Recovery
- Environment Variables
- Service Dependencies
- Pre-Launch & Post-Launch Actions
- Pre-Stop & Post-Stop Actions
- Shutdown & Teardown
- Export/Import Services
- Automation & CI/CD
- Integration with Monitoring Tools
- Service Event Notifications
- Comparison with Alternatives
- Security
- Architecture
- Building from Source
- Troubleshooting
- FAQ