2

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.

tnw
  • 13,521
  • 15
  • 70
  • 111
user2886642
  • 71
  • 1
  • 5
  • can you try $sn=" /ContControllerGroup=$line /username=$Username /password=$Password /unattended ""$ServiceExecutablePath""" . You seem to be missing a forward slash / in front of the first key (ControllerGroup) – Vishnoo Rath Nov 18 '13 at 11:05

1 Answers1

5

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
user2886642
  • 71
  • 1
  • 5