2017-02-18 62 views
-1

我想執行WinRAR.exe。 WinRAR的路徑由一個名爲$a的變量決定。我不知道怎麼糾正下面的代碼:根據變量執行命令

$a = "C:\Program Files\WinRAR" 
$a\WinRAR.exe # this line raises an error 

我能看到的echo $a值:

$a = "C:\Program Files\WinRAR" 
echo $a # "C:\Program Files\WinRAR" is printed 

而且我敢肯定的是,執行C:\"Program Files"\WinRAR\WinRAR.exe可以啓動WinRAR的

有誰知道爲什麼$a\WinRAR.exe不工作?

+1

'&「$ a \ WinRAR.exe」' – PetSerAl

回答

1

真的很簡單。您需要以「&」符號將呼叫前綴添加到winrar。

&$a\winrar.exe