# How to install MSI file to the custom directory using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To install the MSI file to the custom directory using PowerShell, we can use the TARGETDIR, INSTALLDIR, INSTALLPATH, etc arguments for the custom path, depending upon the MSI file that it supports.

msiexec /i "C:\temp\7z1900-x64.msi" INSTALLDIR="D:\ProgramFiles\7zip" /quiet

The above command can be run into PowerShell and cmd both but you can’t control the process that to wait until the installation finishes. To control the above command, we can use the Start-Process cmdlet in PowerShell.

Start-Process -FilePath "C:\windows\system32\msiexec.exe" -ArgumentList "/i
C:\temp\7z1900-x64.msi INSTALLDIR='D:\ProgramFiles\7zip' /quiet" -Wait

If the INSTALLDIR is not supported by the MSI file then you can use the other parameters as specified above or use the logs to check what is the parameter for the default path and apply the path there.

Published on 31-Aug-2021 09:57:11