Can anyone explain to me why:
iex "C:\Program Files\test\test.exe"
C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + C:\Program Files\test\test.exe + ~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Program:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException<hr>
I've tried to get this working multiple different ways:
<li>Wrapping the text in
()</li> <li>Putting the string into a variable and passing it as a variable instead</li> <li>Using single quotes</li> <li>Using double quotes</li> </ul>
I don't know how else I can get it to realize that the entire string must be run, not just the first word.<hr>
The question has been answered. Here is something I was trying to get working:
$tool = "C:\Windows\System32\cmd.exe" $param = "/c ping google.com -n 1" $test = & $tool $param Write-Host $test
It turns out that the line with
& does NOT work with double quotes
"" in this instance, and actually worked without them. I think this has to do with there being arguments/parameters involved.
& operator together with quotes:
& "C:\Program Files\test\test.exe"<hr>
& Call operator Runs a command, script, or script block. The call operator, also known as the "invocation operator," lets you run commands that are stored in variables and represented by strings. Because the call operator does not parse the command, it cannot interpret command parameters. C:\PS> $c = "get-executionpolicy" C:\PS> $c get-executionpolicy C:\PS> & $c AllSigned