Rewrite ExecCommand()

This commit is contained in:
Yorick Barbanneau 2018-03-26 22:17:29 +02:00
parent 1d7d2a6254
commit f7d0a679ac

View file

@ -460,7 +460,6 @@ function DelFile {
write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
}
}
function ExecCommand {
param (
[cmdletbinding(
@ -471,19 +470,22 @@ function ExecCommand {
ParameterSetName="params",
Position = 0
)]
[object]$params
[object]$params
)
Write-Host -NoNewline "`tExecute : $($params.path) : "
if ( -not (Test-Path $params.path) ) {
$path = $params.path.Replace("##mod_path##", $script:current_module_path)
$args = $params.arguments.Replace("##mod_path##", $script:current_module_path)
Write-Host -NoNewline "`tExecute : $path : "
$path = Invoke-Expression """$($path)"""
if ( -not (Test-Path $path) -and -not $path -eq "powershell" ) {
Write-Host -ForegroundColor Yellow "File not found"
return
}
try {
Start-Process $params.path -ArgumentList $params.arguments
Start-Process -wait -filepath $path -ArgumentList $args.split(" ")
Write-Host -ForegroundColor Green "done"
}
catch {
Write-Host -NoNewLine -ForegroundColor Red "`Error in DelFile`n`t"
Write-Host -NoNewLine -ForegroundColor Red "Error`n`t"
write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
}
}