1

I am trying to perform a silent install of IBM Rational Doors 9.7 as explained here.

I want to perform the install with Powershell. I am constructing the arguments to Start-Process to run the installer like this:

$doors97installArgs = '/s /v"/l*v"install.log" /qn INSTALLDIR="C:\Program Files\IBM\Rational\DOORS\9.7.2.3\" CLIENTDATA="36990@<redacted>" LAPAGREE="Yes" TLLICENSESERVER="27200@<redacted>" -wait -verb open'

For Start-Process I am using this:

Start-Process -WorkingDirectory $doors97location -FilePath $doors97setupFullPath -ArgumentList $doors97installArgs

The values in $doors97location and $doors97setupFullPath evaluate correctly.

When Start-Process runs it immediately exits with no error message. What am I doing wrong?

Juan Jimenez
  • 443
  • 4
  • 18

3 Answers3

1

There are two problems with your command:

  • You mistakenly included -wait and -verb open inside the argument-list string passed to Start-Process.

    • Note that -Verb Open is redundant, as it is implied. (-Verb is typically only used with RunAs, to request execution _with elevation).
  • The argument-list string is broken in that the embedded " chars. inside /v"..." aren't escaped.

However, since your intent is to run synchronously (Start-Process -Wait), for simplicity I suggest calling via cmd /c instead, which is implicitly synchronous while giving you the same control over the quoting on the resulting process command lines as with Start-Process; additionally, the installer process' exit code will be reflected in the automatic $LASTEXITCODE variable afterwards.

Based on the docs you link to, try the following (using an expandable here-string to make use of embedded quotes easier):

# Call the installer synchronously.
# 
cmd /c @"
cd /d "$doors97location"
"$doors97setupFullPath" /s /v"/l*v\"install.log\" /qn INSTALLDIR=\"C:\Program Files\IBM\Rational\DOORS\9.7.2.3\" CLIENTDATA=\"36990@<redacted>\" LAPAGREE=\"Yes\" TLLICENSESERVER=\"27200@<redacted>\""
"@  # NOTE: This closing delimiter must be *at the very start* of the line.

After this call, $LASTEXITCODE contains the installer's exit code.

mklement0
  • 382,024
  • 64
  • 607
  • 775
  • 1
    After a chat with IBM the install arguments were adjusted to "/S /v`"/qn CLIENTDATA=\`"36990@\`" LAPAGREE=\`"Yes\`" TLLICENSESERVER=\`"27200@\`"" and it finally worked. Thanks for the help! – Juan Jimenez May 03 '23 at 12:51
  • 1
    Glad to hear it, @JuanJimenez; my pleasure. The `\``-escaping of the embedded `"` chars. is indeed needed if you use a regular `"..."` string literal. With the here-string variant, as shown in the answer, embedded `"` can be used as-is. – mklement0 May 03 '23 at 12:52
-1

There is probably no difference between silently installing a program in cmd or powershell, barring quoting issues. Since I don't see a "start /wait" in the docs, I'm assuming the setup.exe runs in the foreground, and doesn't require start-process to wait for it. If the quoting becomes an issue, it's an option to run the thing inside an install.bat file. I see a lot of backslashed double-quotes there.

C:\doors_server\setup.exe /s /v"/l*v\"C:\doors_server\install.log\" /qn PORTNUMBER=\"36677\" LAPAGREE=\"Yes\" DATABASEDIR=\"C:\Program Files(x86)\IBM\Rational\DOORS\9.version\data\" INSTALLDIR=\"C:\Program Files(x86)\IBM\Rational\DOORS\9.version\""

js2010
  • 23,033
  • 6
  • 64
  • 66
  • 1
    As previously noted, if `setup.exe` is a GUI-subsystem application, there _is_ a difference: with direct invocation, PowerShell executes it _asynchronously_, whereas _from inside a batch file_ it executes _synchronously_. The PowerShell syntax of your command is broken. – mklement0 Apr 30 '23 at 21:41
  • 1
    https://www.ibm.com/docs/en/elms/ermd/9.7.2?topic=doors-installing-client-administration states (note the "click" references): "Review the information, and then click 'Install'. When you are prompted, click 'Finish'." I think it's safe to conclude that we are dealing with a GUI-subsystem application. Leaving aside that your PowerShell syntax is broken (lack of escaping of embedded `"` chars.), additional effort to make the call synchronous is therefore necessary. Since the command may require the _partial_ quoting of arguments as such, the safe choices are `Start-Process -Wait` or `cmd /c`. – mklement0 Apr 30 '23 at 22:13
-2

Looks like Start-Process is trying to interpret something from this string.
Try changing the approach, using Start-Process to run a cmd command.
Like this:

Start-Process -FilePath cmd -WorkingDirectory $doors97location -Wait -ArgumentList '/c', 'setup.exe /s /v"/l*v"install.log" /qn INSTALLDIR="C:\Program Files\IBM\Rational\DOORS\9.7.2.3\" CLIENTDATA="36990@<redacted>" LAPAGREE="Yes" TLLICENSESERVER="27200@<redacted>" -wait -verb open'

Let me know how it turned out, and share any error that might come out.

FranciscoNabas
  • 505
  • 3
  • 9
  • 1
    `Start-Process`, with a single-element `-ArgumentList` argument, copies that argument as-is to the process command line (after possible up-front interpretation by PowerShell, but given that a `'...'` string is used in this case, there is none). By contrast, calling via `cmd.exe` _does_ introduce another layer of interpretation, which can only make matters worse. – mklement0 Apr 28 '23 at 01:20
  • My script already requires Powershell to run as administrator, using cmd will force the user to go through the corp network administrator login again. – Juan Jimenez Apr 28 '23 at 11:38
  • 2
    You guys are right, should have thought about it before posting. – FranciscoNabas Apr 29 '23 at 19:15
  • 1
    Unless you `@`-mention others (which you can only do for one user at a time), they won't be notified of your follow-up comments. Apart from that: It's never too late to either amend or delete your answer. – mklement0 Apr 29 '23 at 22:38