# svcfwin **Repository Path**: InsignificantDust/svcfwin ## Basic Information - **Project Name**: svcfwin - **Description**: windows操作service - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-20 - **Last Updated**: 2025-05-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Svcfwin介绍 一款用于管理windows系统服务的工具,修改指定文件内容,内容采取覆盖式修改,支持windows 10以上版本。 ## 代码编译 要求go版本为1.22,如果没有请自行安装 ``` # 编译 git https://git.qinghong-tech.com:51000/omtools/svcfwin.git cd svcfwin # 国内用户请配置依赖包代理 go env -w GOPROXY=https://goproxy.cn,direct go mod tidy go build -o svcfwin.exe ``` ## 应用配置 配置文件请参考样例文件config-sample.yml ```yaml port: 8080 auth: # 认证头Auth-Token,用户请求认证 token: 1234567890 log: file: svcfwin.log level: info service: # 服务名称,请在服务管理器中查找具体名称 name: nginx file: # 需要操作的文件路径 path: D:\license.lic ``` ## API说明 API请求时,请指定认证头Auth-Token,值为在配置文件中的token中配置 - 查询服务信息,请求方法为GET **/service/query** ``` curl --location --request GET 'http://localhost:8080/service/query' --header 'Auth-Token: Aa123456df' # 以下是返回内容示例 SERVICE_NAME: nginx TYPE : 10 WIN32_OWN_PROCESS STATE : 1 STOPPED WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x7d0 ``` - 启动服务,请求方法为PUT **/service/start** ``` curl --location --request PUT 'http://localhost:8080/service/start' --header 'Auth-Token: Aa123456df' ``` - 停止服务,请求方法为PUT **/service/stop** ``` curl --location --request PUT 'http://localhost:8080/service/stop' --header 'Auth-Token: Aa123456df' ``` - 重启服务,请求方法为PUT **/service/restart** ``` curl --location --request PUT 'http://localhost:8080/service/restart' --header 'Auth-Token: Aa123456dfd' ``` - 查看文件内容,请求方法为GET **/file/query** ``` curl --location --request GET 'http://localhost:8080/file/query' --header 'Auth-Token: Aa123456df' ``` - 修改文件内容,请求方法为POST,请求体为文件内容 **/file/update** ``` curl --location --request POST 'http://localhost:8080/file/update' --header 'Auth-Token: Aa123456df' --header 'Content-Type: text/plain' --data-raw 'afdafdsafda' ```