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
|
write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ExecCommand {
|
function ExecCommand {
|
||||||
param (
|
param (
|
||||||
[cmdletbinding(
|
[cmdletbinding(
|
||||||
|
@ -471,19 +470,22 @@ function ExecCommand {
|
||||||
ParameterSetName="params",
|
ParameterSetName="params",
|
||||||
Position = 0
|
Position = 0
|
||||||
)]
|
)]
|
||||||
[object]$params
|
[object]$params
|
||||||
)
|
)
|
||||||
Write-Host -NoNewline "`tExecute : $($params.path) : "
|
$path = $params.path.Replace("##mod_path##", $script:current_module_path)
|
||||||
if ( -not (Test-Path $params.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"
|
Write-Host -ForegroundColor Yellow "File not found"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Start-Process $params.path -ArgumentList $params.arguments
|
Start-Process -wait -filepath $path -ArgumentList $args.split(" ")
|
||||||
Write-Host -ForegroundColor Green "done"
|
Write-Host -ForegroundColor Green "done"
|
||||||
}
|
}
|
||||||
catch {
|
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
|
write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue