uses get-attr and fixes file path issues by escaping quotes around path
This commit is contained in:
parent
5ff4d219e0
commit
3781c5ccb0
1 changed files with 9 additions and 23 deletions
|
@ -21,52 +21,38 @@
|
|||
|
||||
$params = Parse-Args $args;
|
||||
|
||||
$result = New-Object psobject;
|
||||
Set-Attr $result "changed" $false;
|
||||
$wait = $false
|
||||
$path = Get-Attr $params "path" -failifempty $true
|
||||
$state = Get-Attr $params "state" "present"
|
||||
$creates = Get-Attr $params "creates" $false
|
||||
$extra_args = Get-Attr $params "extra_args" ""
|
||||
$wait = Get-Attr $params "wait" $false | ConvertTo-Bool
|
||||
|
||||
If (-not $params.path.GetType)
|
||||
{
|
||||
Fail-Json $result "missing required arguments: path"
|
||||
}
|
||||
|
||||
If ($params.wait -eq "true" -Or $params.wait -eq "yes")
|
||||
{
|
||||
$wait = $true
|
||||
}
|
||||
|
||||
$extra_args = ""
|
||||
If ($params.extra_args.GetType)
|
||||
{
|
||||
$extra_args = $params.extra_args;
|
||||
}
|
||||
|
||||
If (($creates -ne $false) -and ($state -ne "absent") -and (Test-Path $creates))
|
||||
{
|
||||
Exit-Json $result;
|
||||
}
|
||||
|
||||
$logfile = [IO.Path]::GetTempFileName();
|
||||
If ($params.state.GetType -and $params.state -eq "absent")
|
||||
{
|
||||
If ($wait)
|
||||
{
|
||||
Start-Process -FilePath msiexec.exe -ArgumentList "/x $params.path /qb /l $logfile $extra_args" -Verb Runas -Wait;
|
||||
Start-Process -FilePath msiexec.exe -ArgumentList "/x `"$path`" /qn /l $logfile $extra_args" -Verb Runas -Wait;
|
||||
}
|
||||
Else
|
||||
{
|
||||
Start-Process -FilePath msiexec.exe -ArgumentList "/x $params.path /qb /l $logfile $extra_args" -Verb Runas;
|
||||
Start-Process -FilePath msiexec.exe -ArgumentList "/x `"$path`" /qn /l $logfile $extra_args" -Verb Runas;
|
||||
}
|
||||
}
|
||||
Else
|
||||
{
|
||||
If ($wait)
|
||||
{
|
||||
Start-Process -FilePath msiexec.exe -ArgumentList "/i $params.path /qb /l $logfile $extra_args" -Verb Runas -Wait;
|
||||
Start-Process -FilePath msiexec.exe -ArgumentList "/i `"$path`" /qn /l $logfile $extra_args" -Verb Runas -Wait;
|
||||
}
|
||||
Else
|
||||
{
|
||||
Start-Process -FilePath msiexec.exe -ArgumentList "/i $params.path /qb /l $logfile $extra_args" -Verb Runas;
|
||||
Start-Process -FilePath msiexec.exe -ArgumentList "/i `"$path`" /qn /l $logfile $extra_args" -Verb Runas;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue