Visual Studio 2017 Professional - silent Installation via powershell does not quit
i´m working as a software packager in a german company.
Now i´m facing a strange issue installing Microsoft Visual Studio 2017 Professional (at least it seems being strange to me).
We are using Microsoft SCCM to deploy Software. Each Software package is created as an application in SCCM.
The package itself is using the (ingenious) AppDeployToolkit, so Visual Studio gets installed via PowerShell.
This is the command i am using in the PSADTK to install Visual Studio:
|Execute-Process -Path "$dirFiles\VS.exe" -Parameters @( "--noweb",|
Now when i test the installation of my package on a local virtual machine i call the deployment script from a powershell prompt.
The function Execute-Process is starting the vs.exe and then it´s waiting for the process to finish. As soon as the process has finished, the ExitCode is checked.
Here´s the Problem: Although all processes started by vs.exe are finished, the powershell script doesn´t end. It stays opened and nothing happens.
It even doesn´t matter if i use PSADT or a simple PowerShell prompt to enter the command (as Start-Process [...] -wait -passthru). It´s the same Problem in both cases.
If i create a batch file to execute the vs.exe and call the batch file from PSADTK, the cmd window gets closed after the installation and even is giving me a return code, but the powershell script is still staying open.
If i call the deployment script from Powershell ISE, everything works fine.
I´m confused. And i don`t want to use batch instead of PSADTK for the Installation.
Does anyone have an idea how to solve this?
By the way i want to apologise for my English. I guess it´s not perfect.
Community Chosen Answer
I solved the problem.
There is a process named "xgTrayIcon" which gets started during the installation of VS. As soon as that process gets killed, the installation of VS will finish.
The powershell commandlet "Start-Process" ... -wait -passthru is always waiting for the property ".HasExited" to become true. This is only the case if the process xgTrayIcon gets killed.
But if you call Start-Process with the -wait parameter, the script will not continue until the command is executed completely so killing the xgTrayIcon will never happen.
Here is how i solved it:
Before starting the Installation of VS i call a separate script which first waits until the Installation begins (process VS running), second waits until the process VS is not running anymore (installation finished) and then kills the process xgTrayIcon. I am not waiting for the completion of the script so it is doing its Job in the Background. So as soon as the Installation has finished the xgTrayicon gets killed, the property ".HasExited" becomes true, i get my return code and the script continues...
Maybe this will help someone someday. I would be glad.
If someone would like to see the script(s), let me know.
"VS" is the process name in my case. The name is equal to the exe yo are starting for the installation.
I hope this will help someone someday! :-)