-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_start_service.ps1
More file actions
30 lines (24 loc) · 948 Bytes
/
install_start_service.ps1
File metadata and controls
30 lines (24 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$serviceName = "Websockify"
$webFolder = "C:\projs\rust\websockify-rs\assets"
$websockifyExe = "C:\projs\rust\ws-rs\target\release\websockify-rs.exe"
$vncAddress = "127.0.0.1:5900"
$webHost = "127.0.0.1:9000"
if (Get-Service $serviceName -ErrorAction SilentlyContinue)
{
$serviceToRemove = Get-WmiObject -Class Win32_Service -Filter "name='$serviceName'"
$serviceToRemove.delete()
"service removed"
}
else
{
"service does not exists"
}
"installing service"
# $secpasswd = ConvertTo-SecureString "SomePassword" -AsPlainText -Force
# $mycreds = New-Object System.Management.Automation.PSCredential (".\SomeUser", $secpasswd)
$binaryPath = "$websockifyExe --web $webFolder --source $webHost --target $vncAddress"
# 安装服务
New-Service -name $serviceName -binaryPathName $binaryPath -displayName $serviceName -startupType Automatic -credential $mycreds
# 开启服务
Start-Service -Name $serviceName
"installation completed"