调试时,$var
不等同于“folder\that\isNot\equivalent\".
我尝试将其更改为等效语句,但它无效。任何见解都将不胜感激。
以下是所有相关代码:
$process = "Explorer++.exe"
$var = Get-WmiObject Win32_Process -Filter "name = '$process'" | select -expandproperty CommandLine
$var = $var -split '\\\\' | select -Last 1
Write-Host $var
if ($var -ne "folder\that\isNot\equivalent\")
{
Stop-Process -processname explorer++
Stop-Process -processname curProc
}
else
{
return $true
}
答案 0 :(得分:1)
问题是围绕$ var的空白。我使用了命令$var = $var -replace "\s",""
用空字符串替换每个空格符号,我也将其更改为等效语句。
if ($var -eq "\folder\that\is\")