Install a service( which accepts paramters for installation) using InstallUtil from Powershell

user2886642 picture user2886642 · Oct 16, 2013 · Viewed 7.5k times · Source

I am trying to write a powershell script to install a service which accepts parameter for installation.

The following works in command prompt

C:\Windows\Microsoft.NET\Framework\v4.0.30319>installutil.exe /ControllerGroup=Delivery     /username=userl /password=pwd /unattended    "C:\DocumentProcessingPlatform\Dpp.Service\bin\Debug\Dpp.Service.exe"

However when I try to run installutil from Powershell it does not work and gives me an exception

Powershell Script

$sn = " ControllerGroup=$line /username=$Username /password=$Password /unattended  ""$ServiceExecutablePath""" 
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe $sn

Exception occurred while initializing the installation:
System.ArgumentException: File  ControllerGroup=Delivery /username=usr /password=pwd /unattended C:\DocumentProcessingPlatform\Dpp.Service\bin\Debug\Dpp.Service.exe does not exist. If this parameter is used as an installer option, the format must be
/key=[value]..

How can I pass the parameters to installutil? Any help is appreciated.

Answer

user2886642 picture user2886642 · Nov 19, 2013

Got it working by using the Start-Process cmdlet

$x=""

$x = "/ControllerGroup=$controllerGroup”, “/username=$Username” , "/password=$Password", "/unattended" , $ServiceExecutablePath

Start-Process –FilePath C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe –ArgumentList $x –NoNewWindow