Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 84 additions & 42 deletions en/guide/network/install-as-a-windows-service.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,115 @@
# Install as a Windows Service

> Thanks to BeiChen℃ for providing the tutorial, and dawn-lc for providing the one-click install/uninstall script
After EasyTier is installed as a Windows service, it can run in the background and start automatically with the system. This is useful for long-running or unattended deployments.

On Windows systems, installing certain applications as services allows them to run automatically in the background without manual intervention, greatly improving the stability and convenience of the application.
The recommended approach is to use the official `install.cmd` script for installation, updates, and removal. You no longer need to prepare NSSM manually.

This tutorial will use NSSM (Non-Sucking Service Manager) to install the EasyTier application as a Windows service as an example, and provide a detailed explanation of the entire operation process.
> Thanks to BeiChen℃ for the original tutorial and dawn-lc for the one-click install/uninstall script.

## 1. Preparation
## Quick Start

**Download EasyTier Application**:
Open PowerShell in your EasyTier directory and run:

Download the latest version of the `Windows` operating system `command line program` compressed package.
```PowerShell
iwr "https://raw.githubusercontent.com/EasyTier/EasyTier/main/script/install.cmd" -OutFile "install.cmd"; .\install.cmd
```

After downloading, extract the compressed package to a local directory, such as `D:\EasyTier`.
If GitHub is not accessible, use the mirror proxy command instead:

The current directory should contain at least the following files:
```PowerShell
iwr "https://ghfast.top/https://raw.githubusercontent.com/EasyTier/EasyTier/main/script/install.cmd" -OutFile "install.cmd"; .\install.cmd -ughp
```

- `easytier-core.exe` (core program)
- `easytier-cli.exe` (command line tool)
- `Packet.dll` (runtime library)
- `wintun.dll` (runtime library)
The script will guide you through the setup and start the service automatically after installation succeeds.

**Download NSSM**:
## Before You Start

Open your browser and visit the NSSM official website [https://nssm.cc/](https://nssm.cc/download).
1. Download the latest Windows command line package.
2. Extract it to a fixed directory such as `D:\EasyTier`.
3. Download `install.cmd` into the same directory:

On the official website page, find the version suitable for your system (usually the latest version), click the download link to download it locally.
```PowerShell
iwr "https://raw.githubusercontent.com/EasyTier/EasyTier/main/script/install.cmd" -OutFile "install.cmd"
```

After downloading, find the version corresponding to your device architecture (such as: `win64`), and extract the `nssm.exe` from it to the local directory where `EasyTier` is located.
4. Make sure the directory contains at least these files:

**Download Install/Uninstall Script**:
- `easytier-core.exe`
- `easytier-cli.exe`
- `Packet.dll`
- `wintun.dll`
- `install.cmd`

Start PowerShell in the current directory and execute the following commands:
Do not move this directory after installation, or the service path configuration may break.

`iwr "https://github.com/EasyTier/EasyTier/raw/refs/heads/main/script/install.cmd" -OutFile "install.cmd"`
## Installation Steps

`iwr "https://github.com/EasyTier/EasyTier/raw/refs/heads/main/script/uninstall.cmd" -OutFile "uninstall.cmd"`
1. Open PowerShell in the EasyTier directory.
2. Run the install script:

## 2. Preparation Work
```PowerShell
.\install.cmd
```

1. Ensure the current directory contains the following files:
3. Choose a configuration mode and provide the required values when prompted.
4. After the script finishes, the Windows service is created and started automatically.

- `easytier-core.exe` (core program)
- `easytier-cli.exe` (command line tool)
- `nssm.exe` (service management tool)
- `Packet.dll` (runtime library)
- `wintun.dll` (runtime library)
- `install.cmd` (install script)
- `uninstall.cmd` (uninstall script)
## Configuration Modes

2. Place the entire folder in a fixed location.
- `File`: use a local configuration file. Best when you already have a config file prepared.
- `Remote`: use centralized management from a remote server. Best for managing multiple devices.
- `CLI`: pass parameters directly on the command line. Best for quick testing or custom startup arguments.

## 3. Install Service
## Common Commands

1. Run `install.cmd`
2. Follow the prompts to enter configuration information.
3. After installation is complete, the service will start automatically.
- Install the service:

## 4. Uninstall Service
```PowerShell
.\install.cmd
```

1. Run `uninstall.cmd`
2. The script will automatically stop and delete the service.
- Uninstall the service:

## 5. Notes
```PowerShell
.\install.cmd -Uninstall
```

1. Do not move the program file location after installation
- Update EasyTier:

## 6. Common Questions
```PowerShell
.\install.cmd -Update
```

**Q: How to modify service configuration?**
## Parameter Reference

A: First uninstall the service, then reinstall it
### Basic

- `-H` / `-?` / `-Help`: show help information and exit.

### Service Actions

- `-U` / `-Update`: update EasyTier to the latest version.
- `-X` / `-Uninstall`: uninstall the EasyTier service.

### Download Proxies

- `-UGHP` / `-UseGitHubProxy`: download through a GitHub mirror proxy. Default: `$false`.
- `-GHP` / `-GitHubProxy <proxy>`: specify the GitHub mirror proxy address. Default: `https://ghfast.top/`.
- `-UP` / `-UseProxy`: use a custom proxy. Default: `$false`.
- `-P` / `-Proxy <proxy>`: specify the custom proxy address. Default: `http://127.0.0.1:7890`.

### Configuration and Service Name

- `-C` / `-ConfigType <type>`: set the configuration mode. Supported values: `File`, `Remote`, `CLI`.
- `-N` / `-ServiceName <name>`: set the installed service name. Default: `EasyTierService`.
- `<other arguments...>`: when `CLI` mode is used, any remaining arguments are passed to EasyTier.

## FAQ

**Q: How do I change the service configuration?**

A: First run `.\install.cmd -Uninstall`, then install the service again with the new configuration.

**Q: Why should I keep the directory in the same place after installation?**

A: The Windows service stores the paths to the EasyTier executables and script. If the directory moves, the service may fail to start.
125 changes: 84 additions & 41 deletions guide/network/install-as-a-windows-service.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,115 @@
# 安装为 Windows 服务

> 感谢 北辰℃ 提供的教程,以及由 dawn-lc 提供的一键安装/卸载脚本
将 EasyTier 安装为 Windows 服务后,它可以在后台自动运行,并支持随系统启动,适合长期在线或无人值守的场景。

在 Windows 系统中,将某些应用程序安装为服务可以使其在后台自动运行,无需用户手动干预,极大地提高了应用的运行稳定性和便捷性
当前推荐直接使用官方 `install.cmd` 脚本完成安装、更新和卸载,无需再手动准备 NSSM

本教程将以使用 NSSM(Non-Sucking Service Manager)工具将 EasyTier 应用安装为 Windows 服务为例,详细介绍整个操作流程
> 感谢 北辰℃ 提供的教程,以及 dawn-lc 提供的一键安装/卸载脚本

## 一、前期准备
## 快速开始

**下载 EasyTier 应用**
推荐直接在 EasyTier 文件目录中打开 PowerShell,然后执行

下载最新版本的 `Windows` 操作系统的 `命令行程序` 压缩包。
```PowerShell
iwr "https://raw.githubusercontent.com/EasyTier/EasyTier/main/script/install.cmd" -OutFile "install.cmd"; .\install.cmd
```

下载完成后,将该压缩包解压到本地目录,比如`D:\EasyTier`。
如果无法访问 GitHub,可以使用镜像代理:

当前目录下应至少包含以下文件:
- `easytier-core.exe` (核心程序)
- `easytier-cli.exe` (命令行工具)
- `Packet.dll` (运行库)
- `wintun.dll` (运行库)
```PowerShell
iwr "https://ghfast.top/https://raw.githubusercontent.com/EasyTier/EasyTier/main/script/install.cmd" -OutFile "install.cmd"; .\install.cmd -ughp
```

**下载 NSSM**:
脚本会根据提示完成配置,并在安装成功后自动启动服务。

打开浏览器,访问 NSSM 官网 [https://nssm.cc/](https://nssm.cc/download)。
## 安装前准备

在官网页面中找到适用于你系统的版本(通常是最新版本),点击下载链接将其下载到本地。
1. 下载最新版本的 Windows 命令行程序压缩包。
2. 将压缩包解压到固定目录,例如 `D:\EasyTier`。
3. 在该目录中下载 `install.cmd`:

下载完成后,找到对应您设备架构的版本(如:`win64`),将其中的`nssm.exe`解压到`EasyTier`所在的本地目录。
```PowerShell
iwr "https://raw.githubusercontent.com/EasyTier/EasyTier/main/script/install.cmd" -OutFile "install.cmd"
```

4. 确认目录中至少包含以下文件:

**下载 安装/卸载 脚本**:
- `easytier-core.exe`
- `easytier-cli.exe`
- `Packet.dll`
- `wintun.dll`
- `install.cmd`

在当前目录下启动PowerShell并执行以下命令:
安装完成后请不要移动该目录,否则服务配置中的路径会失效。

`iwr "https://github.com/EasyTier/EasyTier/raw/refs/heads/main/script/install.cmd" -OutFile "install.cmd"`
## 安装流程

`iwr "https://github.com/EasyTier/EasyTier/raw/refs/heads/main/script/uninstall.cmd" -OutFile "uninstall.cmd"`
1. 在 EasyTier 所在目录中打开 PowerShell。
2. 运行安装脚本:

## 二、准备工作
```PowerShell
.\install.cmd
```

1. 确保当前目录下包含以下文件:
- `easytier-core.exe` (核心程序)
- `easytier-cli.exe` (命令行工具)
- `nssm.exe` (服务管理工具)
- `Packet.dll` (运行库)
- `wintun.dll` (运行库)
- `install.cmd` (安装脚本)
- `uninstall.cmd` (卸载脚本)
3. 根据提示选择配置模式,并填写所需参数。
4. 安装完成后,脚本会自动创建并启动 Windows 服务。

2. 将整个文件夹放在固定位置。
## 配置模式说明

## 三、安装服务
- `File`:使用本地配置文件,适合已经准备好配置文件的场景。
- `Remote`:使用远程服务器集中管理,适合统一维护多台设备。
- `CLI`:直接通过命令行传参启动,适合临时调试或自定义参数较多的场景。

1. 运行`install.cmd`
2. 按照提示输入配置信息。
4. 安装完成后会自动启动服务。
## 常用命令

## 四、卸载服务
- 安装服务:

1. 运行`uninstall.cmd`
2. 脚本会自动停止并删除服务。
```PowerShell
.\install.cmd
```

## 五、注意事项
- 卸载服务:

1. 安装后不要移动程序文件位置
```PowerShell
.\install.cmd -Uninstall
```

## 六、常见问题
- 更新 EasyTier:

```PowerShell
.\install.cmd -Update
```

## 参数参考

### 基础参数

- `-H` / `-?` / `-Help`:显示帮助信息并退出。

### 服务操作

- `-U` / `-Update`:更新 EasyTier 到最新版本。
- `-X` / `-Uninstall`:卸载 EasyTier 服务。

### 下载代理

- `-UGHP` / `-UseGitHubProxy`:使用 GitHub 镜像代理下载,默认值为 `$false`。
- `-GHP` / `-GitHubProxy <代理地址>`:指定 GitHub 镜像代理地址,默认值为 `https://ghfast.top/`。
- `-UP` / `-UseProxy`:使用自定义代理,默认值为 `$false`。
- `-P` / `-Proxy <代理地址>`:指定自定义代理地址,默认值为 `http://127.0.0.1:7890`。

### 配置与服务名

- `-C` / `-ConfigType <类型>`:指定配置模式,可选值为 `File`、`Remote`、`CLI`。
- `-N` / `-ServiceName <名称>`:指定安装后的服务名,默认值为 `EasyTierService`。
- `<其他参数...>`:当使用 `CLI` 模式时,会作为额外参数传递给 EasyTier。

## 常见问题

**Q: 如何修改服务配置?**

A: 先卸载服务,然后重新安装
A: 先执行 `.\install.cmd -Uninstall` 卸载服务,再使用新的配置重新安装。

**Q: 为什么安装后不能移动目录?**

A: Windows 服务会记录 EasyTier 可执行文件和脚本所在路径,移动目录后服务可能无法正常启动。