Execute-ProcessAsUser hidden window

Hi all,
Recently I discovered PSAppDeployToolkit and it will be really benefit in my company to deploy applications in specific cases, thank you for the project, very appreciated.

The first thing I want to do is to deploy an new version of MSRDC, no problem with that. But I would like to clean up old user installs. This is why I use Execute-ProcessAsUser.

I’m using the command presented in the example with ps.exe which works fine but displays a ps.exe window for a short time.

Execute-ProcessAsUser -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"msiexec.exe /x '$GUID' /qn`"; Exit `$LastExitCode }" -Wait

I have already seen in another topic that the Execute-ProcessAsUser creates a scheduled task for snapshot and there is no possibility to hide a ps.exe window through scheduled task.
I already tried to add “-WindowStyle Hidden” but yeah, that change nothing.

So I tried to push directly the msiexec.exe command but I’m not able to make it works. Any advices?

Execute-ProcessAsUser -Path "$WINDIR\System32\msiexec.exe" -Parameters "/x '$GUID' /qn"; Exit `$LastExitCode }" -Wait

Thank you all by advance,

I have founded the right synthax thanks to log file “C:\Windows\Logs\Software”:

Execute-ProcessAsUser -Path "$envSystem32Directory\msiexec.exe" -Parameters "/x $GUID /qn" -Wait

Two errors:

  • I did not use Toolkit Variables
  • I kept the exit code, this is only used with ps.exe executable