diff --git a/cleanW10.ps1 b/cleanW10.ps1 index 715cc6c..35faef9 100755 --- a/cleanW10.ps1 +++ b/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 } }