Install msi as logged in user

I’m trying to use execute-processasuser because this terrible msi will not accept the allusers flag. so it defaults to the installing for the user who runs the process instead of all users. Here’s my line for execute-processasuser and the app is not getting installed at all.

$PCUser is a variable that gets built from parsing the pc name.

Execute-ProcessAsUser -UserName “$PCUser” -Path “msiexec.exe” -Parameters “/I “”$dirFiles\bad.msi”" /qn /norestart"

what am i missing?

Is the location of the msi accessible to this user?

it’s running as a pre-install step so the msi at that point would be in the users ccmcache directory and the user can access that.

Try the below and use /qb so you can see what message is being sent.

Execute-ProcessAsUser -UserName “$PCUser” -Path “$envSystem32Directory\msiexec.exe” -Parameters “/i "$dirFiles\bad.msi" /qb REBOOT=R”

(make sure that the quotes are not fancy quotes)

I know it’s not good practice to do so, but in such situations when an MSI is misbehaving, I have had to resort to recapturing it a time or two.

When you’re trying to install as ALLUSERS=1, are you running as SYSTEM account or just with a user with administrative credentials? Some custom actions made by vendors also don’t like the SYSTEM account profile layout.

Installing an MSI for the user can get messy to manage later, particularly if a machine gets recycled or it’s shared and a second user wants to access that MSI.

I am usually using SCCM to deploy or an elevated user id when testing. Does it work with an elevated user account and not via SCCM? I have seen that before but it has been awhile. We used to have a dedicated admin account that we would use for those apps. Or, like you said, you can recapture it. What is the MSI?

Well indeed you need to disable UAC.

To disable ->
Invoke-Command -ComputerName $computer -ScriptBlock {Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0 -Force}

To enable ->
Invoke-Command -ComputerName $computer -ScriptBlock {Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 5 -Force}