- For
install.ps1
powershell -Command "& { Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/uditgaurav/windows-service/master/bin/install.ps1' -OutFile 'install.ps1' -UseBasicParsing; .\install.ps1 -AdminPass 'Your Password' -InfraId 'YourInfraId' -AccessKey 'YourAccessKey' -ServerUrl 'YourServerUrl' -LogDirectory 'YourLogDirectory' -TaskPollIntervalSeconds 5 -TaskUpdateIntervalSeconds 5 -UpdateRetries 5 -UpdateRetryIntervalSeconds 5 -ChaosInfraLivenessUpdateIntervalSeconds 5 -ChaosInfraLogFileMaxSizeMb 5 -ChaosInfraLogFileMaxBackups 2 -CustomTlsCertificate 'YourCustomTlsCertificate' -HttpProxy 'YourHttpProxy' -HttpClientTimeout '30s' }"
- For
uninstall.ps1
powershell -Command "& { Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/uditgaurav/windows-service/master/bin/uninstall.ps1' -OutFile 'uninstall.ps1' -UseBasicParsing; .\uninstall.ps1 -ServiceName 'WindowsChaosInfrastructure' -TimeoutSeconds 180 -ChaosBaseDirectory 'C:\HCE' -CheckIntervalSeconds 10 }"
GOOS=windows GOARCH=amd64 go build
windows-service.exe*
- Use Windows Service Control Manager to install the service
- https://learn.microsoft.com/en-us/windows/win32/services/service-control-manager
C:\Users\Administrator\Downloads>sc create WindowsChaosAgent binPath= "C:\Users\Administrator\Downloads\windows-chaos-agent.exe"
[SC] CreateService SUCCESS
C:\Users\Administrator\Downloads>sc start WindowsChaosAgent
SERVICE_NAME: WindowsChaosAgent
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 1980
FLAGS :

C:\Users\Administrator\Downloads>sc query WindowsChaosAgent
SERVICE_NAME: WindowsChaosAgent
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
C:\Users\Administrator\Downloads>sc delete WindowsChaosAgent
[SC] DeleteService SUCCESS
- Batch script for installation of the service in Administrator mode.
- Pass flags to the service for input or override the chaos parameters.
- Proper event logging in windows eventviewer.
- Service Management - that is via manual trigger or system trigger.
- Once the agent is running it should be able to run the powershell script in administrator mode.
- Cleanup script.