25 lines
1.1 KiB
PowerShell
25 lines
1.1 KiB
PowerShell
$cloudinitUrl = "https://s3.jonasled.de/share/cloudinit-windows-amd64.exe"
|
|
$nssmUrl = "https://nssm.cc/release/nssm-2.24.zip"
|
|
$workDir = 'C:\Cloud-Init'
|
|
$cloudInitTargetPath = "$workDir\cloud-init.exe"
|
|
$nssmTargetPath = "$workDir\nssm.zip"
|
|
$nssmPath = "$workDir\nssm-2.24\win64\nssm.exe"
|
|
$serviceName = "Cloud-Init"
|
|
|
|
|
|
New-Item -Path "c:\" -Name "Cloud-Init" -ItemType "directory"
|
|
|
|
Write-Host "Downloading Cloud-Init..."
|
|
$ProgressPreference = 'SilentlyContinue'
|
|
Invoke-WebRequest -Uri $cloudinitUrl -OutFile $cloudInitTargetPath
|
|
|
|
Write-Host "Downloading NSSM..."
|
|
Invoke-WebRequest -Uri $nssmUrl -OutFile $nssmTargetPath
|
|
|
|
Expand-Archive -LiteralPath $nssmTargetPath -DestinationPath $workDir
|
|
Remove-Item $nssmTargetPath
|
|
|
|
Start-Process -FilePath $nssmPath -ArgumentList "install $serviceName $cloudInitTargetPath" -NoNewWindow -Wait
|
|
Start-Process -FilePath $nssmPath -ArgumentList "set $serviceName AppDirectory $workDir" -NoNewWindow -Wait
|
|
Start-Process -FilePath $nssmPath -ArgumentList "set $serviceName Start SERVICE_AUTO_START" -NoNewWindow -Wait
|
|
Start-Process -FilePath $nssmPath -ArgumentList "set $serviceName AppExit Default Ignore" -NoNewWindow -Wait
|