3

I am seeing some odd behavior running the installer for Autodesk 3D Studio Max 2021. The key issue with an Autodesk installer is it is actually a staged installer, you launch an EXE, which reads data from some XML files, and launches a number of other installers, both EXE and MSI.

Autodesk provides a BAT file for automation, which looks like this

chcp 65001
"\\px\Rollouts\ADSK\2021\3ds_Max_2021\Deployment\image\Installer.exe" -i deploy -q --offline_mode -o \\px\Rollouts\ADSK\2021\3ds_Max_2021\Deployment\image\Deployment.xml -m \\px\Rollouts\ADSK\2021\3ds_Max_2021\Deployment\image\{35156605-CE91-4AF6-8207-56211CB30369}\setup.xml
Echo Done
timeout /t 600

I added the echo and timeout lines to verify when control returns to the BAT file, given that they are not using Start /wait.

I have also migrated the install from the BAT to a PS1 like this

$executable = '"\\px\Rollouts\ADSK\2021\3ds_Max_2021\Deployment\image\Installer.exe"'
$deploymentXML = '"\\px\Rollouts\ADSK\2021\3ds_Max_2021\Deployment\image\Deployment.xml"'
$setupXML = '"\\px\Rollouts\ADSK\2021\3ds_Max_2021\Deployment\image\{35156605-CE91-4AF6-8207-56211CB30369}\setup.xml"'

$argumentList = "-i deploy -q --offline_mode -o $deploymentXML -m $setupXML"

$exitCode = (Start-Process -FilePath $executable -Argumentlist $argumentList -Wait -ErrorAction Stop -PassThru).ExitCode

Write-Host "TaskExitCode: $exitCode"

In theory this should work. The installer runs while PowerShell waits for it to complete, and on completion control returns to PowerShell and the message is displayed. But in PowerShell that never happens, control never returns to PowerShell. At least in Windows 10. In Windows 7 it works as expected. And the BAT file works as expected in both cases.

One of the items being installed by the main install is something called Autodesk Desktop App, which is a service that runs and check for updates. If I remove this from the install (it's a simple XML edit) then control returns to PowerShell and the message displays as expected, even in Windows 10.

So, my question is, does this make sense, that Start-Process -wait is perhaps waiting on a service that was installed and started by the EXE called by Start-Process? And that this should only happen in later versions of Powershell? I have tested a number of different products, with and without Desktop App installing, and removing it allows the main install to properly complete and return control as expected, but I want to know WHY this works, since my sample for testing is rather limited. I want to be sure there isn't some other possible explanation.

Gordon
  • 6,257
  • 6
  • 36
  • 89
  • I think that your hypothesis that it waits for the child processes to finish is correct since if I do `$exitCode = (Start-Process -FilePath cmd.exe -Wait -ErrorAction Stop -PassThru).ExitCode` then close cmd, it works fine, but when I open notepad from cmd then close cmd, it still waits until I close notepad. – Nico Nekoru Jun 28 '20 at 15:44
  • Try without `-PassThru`, *```Returns a process object for each process that the cmdlet started. By default, this cmdlet does not generate any output.```* – Nico Nekoru Jun 28 '20 at 16:12
  • 1
    But without `-PassThru` you can't get a return code back, which is pretty fundamental when automating installs. Is there some other mechanism that would allow knowing what the installer status was at completion? – Gordon Jun 28 '20 at 17:09
  • On windows 7, what version of PowerShell were you using? – Nico Nekoru Jun 28 '20 at 17:11
  • I have tested it on PS2.0 and PS 5.0. Both behave the same. The Win10 VM is running PS 5.1. Perhaps worth testing Win with PS 5.1. – Gordon Jun 28 '20 at 17:17
  • So in 2.0 and 5.0 it works but on Win10 5.1 it doesn't? Is that correct? – Nico Nekoru Jun 28 '20 at 17:21
  • 1
    @neko-musume Yes, and it seems to be a 5.1 issue, as upgrading my Windows 7 VM from 5.0 to 5.1 causes the issue to present. – Gordon Jun 28 '20 at 19:05
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/216842/discussion-between-neko-musume-and-gordon). – Nico Nekoru Jun 28 '20 at 19:22
  • Well, it would seem that Microsoft introduced a bug in PowerShell 5.1, which causes this change in behavior. It would be nice to have a verification of that posted, for others who run into the same issue. – Gordon Jun 28 '20 at 19:52

0 Answers0