1

I've a windows service installed and working fine with a path to exe :

c:\myproject\mybinary.exe -home d:\home - generateFiles false

I want to add another option : -option optionValue

Since I have around 200 different services, installed in a 15 different servers, it is complicated to uninstall and reinstall with the new option.

Is there somehow to add the new option without any change to the service binary?

Umair M
  • 8,566
  • 3
  • 33
  • 67
albarmat
  • 149
  • 1
  • 2
  • 10

1 Answers1

0

PowerShell:

Get-WmiObject win32_service -filter "Name='My Service'" `
    | Invoke-WmiMethod -Name Change `
    -ArgumentList @($null,$null,$null,$null,$null, `
    "c:\myproject\mybinary.exe -home d:\home -generateFiles false -option optionValue")

Or:

Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\My Service" `
    -Name ImagePath -Value "c:\myproject\mybinary.exe -home d:\home -generateFiles false -option optionValue"

You would need to restart service afterwards: Restart-Service "My Service". See also here.

Community
  • 1
  • 1
Anton Krouglov
  • 2,374
  • 1
  • 24
  • 43