I've got a simple problem. I've only found two ways that will actually run my msi file, and neither of them will work.
Pay close attention to my usage of '
and "
.
Simply put, I want a way to do this:
$Basics = "$PSScriptRoot"
Start-Process msiexec.exe -Wait -ArgumentList "/i $Basics\Installer_.64 bit_.msi /passive /norestart"
However the string being given to -ArgumentList
is invalid, and I'm not sure why. I've done a lot of attempts as you can see below, in trying to get this right.
$Basics
is just a copy of $PSScriptRoot
for now, but I want it has a separate variable in case if I change it in the future.
/passive /norestart
is removed for testing purposes.
Note: This is not the actual installer file's name. This is made just to contain all the weird characters (.
,_
,) that some of the installers I'm trying to run with this, have. Basically a worst case scenario.
Also, sorry in advance that this is a lot to read, I'm not really sure how to format it better. Go ahead and edit if you know a better way.
Attempts:
Not in order, organized by what kind of attempt it was. My first attempt was "/i '$Basics\Installer_.64 bit_.msi'"
Start-Process msiexec.exe -Wait -ArgumentList "/i $Basics\Installer_.64 bit_.msi"
^ Result: Opens generic Windows Installer help window.
Start-Process msiexec.exe -Wait -ArgumentList "/i '$Basics\Installer_.64 bit_.msi'"
^ Result: Opens generic Windows Installer help window.
Start-Process msiexec.exe -Wait -ArgumentList '/i $Basics\Installer_.64 bit_.msi'
^ Result: "This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package."
Start-Process msiexec.exe -Wait -ArgumentList '/i "$Basics\Installer_.64 bit_.msi"'
^ Result: "This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package."
Start-Process msiexec.exe -Wait -ArgumentList "/i Installer_.64 bit_.msi"
^ Result: Works; However, this isn't acceptable as I need to be able to put a variable in the directory.
Start-Process msiexec.exe -Wait -ArgumentList '/i "C:\Users\Administrator\Downloads\flashdrive\redist\Install (x86 Office)\Installer_.64 bit_.msi"'
^ Result: Works; However, this isn't acceptable as I need to be able to put a variable in the directory.
Start-Process msiexec.exe -Wait -ArgumentList "/i C:\Users\Administrator\Downloads\flashdrive\redist\Install (x86 Office)\Installer_.64 bit_.msi"
^ Result: Opens generic Windows Installer help window.
Start-Process msiexec.exe -Wait -ArgumentList "/i .\Installer_.64 bit_.msi"
^ Result: "This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package."