Process start
There are more ways to do this. First use the Start-Process :
$p = '-h 3 google.com' start-process tracert -arg $p
A new window will appear. If you want to start the process inside the console, just start it with -NoNewWindow
$p = '-h 3 google.com' start-process tracert -arg $p -nonew $params = "-New Application" start-process "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\mage.exe" -arg $params -nonew
Invoke expression
Invoke-Expression can also help. But this is complicated because you have spaces in the path to the executable. This works because there is no place in the path:
$p = '-h 3 google.com' invoke-expression "tracert $p"
But if there is a space, you need to use & inside:
$params = "-New Application" Invoke-Expression "& ""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\mage.exe"" $params"
Note that the "& ""C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\mage.exe"" $params" expands to this:
& "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\mage.exe" -New Application
What did you want. But if there is a space in one of the parameters again, then again .. you need to quote it:
$file1 = 'c:\test path\file1.txt' $file2 = 'c:\test path\file2.txt' $params = """$file1"" ""$file2""" Invoke-Expression "& someexecutable $params"
The analysis is rather complicated: |
stej
source share