Forum Discussion
Script to update files
I'm writing a chocolatey installation script which installs a service from a zip file. (ziplocation = C:\Reference\file.zip)
At the end of script, I want to stop the service, replace/update the files and then start the service
Stop-service "nameofservice"
Compress-Archive -Path C:\Reference\file.zip -Update -DestinationPath C:\Archives\Draft.Zip
Start-service "nameofservice"
it's the correct one or anything extra too be added. Any suggestions highly recommended
Don't know what service it is and how it behaves, but a stop-service -force:$true is perhaps an option and a check before starting the service if it's actually stopped and kill it if not? Something like: if ((get-service -name nameofservice).status -ne 'Stopped') {get-process nameofprocess | stop-process -force}
- ThatcoderCopper Contributor
Thanks perhaps it helps.
- What was your final version of the script?