0

I have a custom Windows service developed in house and deployed on a client's server. It's installed using a PowerShell command similar to the following:

$serviceUser = Get-Credential
New-Service -Name 'service-name' -DisplayName 'service-name' -Description 'This service does things' -BinaryPathName 'C:\path\to\my\service.exe' -StartupType Automatic -Credential $serviceUser

I need to back up this service's files and configuration and be able to restore them. I can back up the files myself using Robocopy or something similar, but I don't know of a way to back up the service configuration itself (credentials, start up settings, name, etc.).

If it were my decision, I'd be looking at just snapshotting the whole machine and restoring from back up. (It'd save me a lot of trouble.) Unfortunately, the client's administration has forbidden using this as the mechanism for back up/restore.

PowerShell commands or calls to executables from it are very strongly preferred, but I could do something graphical if that's the only thing available. PowerShell is the default 4.0 that comes with Windows 2012.

How can I back up/restore a Windows service?

4
  • I feel like this should be a duplicate, but I've been unable to find one.
    – jpmc26
    Aug 8, 2017 at 3:31
  • Service settings are kept in the registry - HKLM, system, currentcontrolset, services I think. Does backing that up do the job? I'm not sure if credentials are stored the too.. Aug 8, 2017 at 7:48
  • @JimReesPotter It doesn't appear so. I've made sure it's configured with a actual user and a password, but it only contains the values (Default), Description, DisplayName, ErrorControl, ImagePath, ObjectName (which contains the credential user name), Start, and Type. There are no subkeys. I suppose it could be somewhere else entirely in the registry, but I have no idea where.
    – jpmc26
    Aug 8, 2017 at 18:18
  • Ok so can you set credentials via SC? And copy everything else in via registry? Aug 9, 2017 at 8:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy