Rewrite ExecCommand()
This commit is contained in:
parent
1d7d2a6254
commit
f7d0a679ac
1 changed files with 8 additions and 6 deletions
14
cleanW10.ps1
14
cleanW10.ps1
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue