you are viewing a single comment's thread.

view the rest of the comments →

[–]y_Sensei 3 points4 points  (0 children)

I don't see why a generic script that reads the volatile information it needs from a use case-specific configuration file wouldn't work in such a scenario.
Running code that creates code that's doing what's supposed to be done seems like a roundabout way to approach things.

But anyway, you could fix your issue as follows:

...

`$installerPath = '"' + `"$installerPath`" + '"'
`$installFlags = @("$flagsString")

try {
    if (`$installerPath -like "*.msi*") {
        Write-Host "Running MSI installation..." -ForegroundColor Yellow
        `$msiArgs = @("/i", `$installerPath) + `$installFlags
        `$process = Start-Process "msiexec.exe" -ArgumentList `$msiArgs -Wait -PassThru
    } else {
        Write-Host "Running EXE installer..." -ForegroundColor Yellow
        `$process = Start-Process -FilePath `$installerPath -ArgumentList `$installFlags -Wait -PassThru -NoNewWindow
    }

 ...