I'm using the following PowerShell command to automatically close a application:
Get-Process | Where-Object {$_.Path -like "G:\TCAFiles\Users\ywxychtb\930\plugins\minorating\MinoRatingPlugin.exe"} | Stop-Process -Force
I need this to run in a .bat script and found that I can use the following command in the command prompt to do this:
PowerShell -command "& {Get-Process | Where-Object {$_.Path -like "G:\TCAFiles\Users\ywxychtb\930\plugins\minorating\MinoRatingPlugin.exe"} | Stop-Process -Force }"
Unfortunately it gives me the following error:
At line:1 char:45
+ & {Get-Process | Where-Object {$_.Path -like G:\TCAFiles\Users\ywxychtb\930\plug ...
+
~
You must provide a value expression following the '-like' operator.
At line:1 char:46
+ & {Get-Process | Where-Object {$_.Path -like G:\TCAFiles\Users\ywxychtb\930\plug ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'G:\TCAFiles\Users\ywxychtb\930\plugins\minorating\MinoRatingPlugin.exe' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : ExpectedValueExpression
Any idea what is wrong?
I've already tried putting ' and "'s around the $_.Path -like "G:\TCAFiles\Users\ywxychtb\930\plugins\minorating\MinoRatingPlugin.exe part, but this didn't help.