Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing a parameter to a service installer via installutil

Tags:

c#

powershell

I'm trying to write a power shell script to install a service but the service requires an extra command line paramiter passed to it. Im having trouble getting this passed over.

Here is the service installer that uses the parameter;

this.serviceInstaller.ServiceName = string.Format("My brill service {0}",this.Context.Parameters["environment"])

And I have tried passing the paramiter in two ways;

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe "C:\foo\bar.exe /environment:tomtest"

(this gives the error "invalid directory on url")

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /environment:tomtest "C:\foo\bar.exe"

(this just dosent change the service name)

Any ideas? Thanks

like image 626
Tom Squires Avatar asked Oct 02 '12 15:10

Tom Squires


1 Answers

I was very close. An equals sign = has to be used to assign the value of the parameter (not a colon :):

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /environment=tomtest "C:\foo\bar.exe"
like image 107
Tom Squires Avatar answered Sep 28 '22 06:09

Tom Squires