2013-01-09 95 views
0

請參閱在PS我的第一個代碼,如下: 我創建了一個Test.ps1文件,包括下面的代碼:文件基本操作

$path = D:\Five-Levels_Deep_Subfolder\Data 

$file = A_Very_Long_INI_FileName.ini 

#If $file exists, Delete it: 
if (Test-Path + $path) { Remove-Item $path + $file } 

#Run the following Application: 
& $path + myApplication.exe 

但是,結果試圖讓我害怕了一些可怕的錯誤消息。事實上,上述代碼中沒有一個是沒有錯誤的。

請耐心等待PS小孩,並幫助我取得巨大成功:-)。

回答

1

試試這個

$path = "D:\Five-Levels_Deep_Subfolder\Data"  
$file = "A_Very_Long_INI_FileName.ini"  
$filepath = join-path $path $file  
#If $filepath exists, Delete it:  
if (Test-Path $filepath) { Remove-Item $filepath}  
#Run the following Application: 
& ($path + "\myApplication.exe") 
+0

謝謝基督徒。一切正常,除了 &($ path +「\ IllustratorPortable.exe」) 錯誤消息報告「不被識別爲cmdlet的名稱,函數,......」 您是否願意查看它再次! –

+0

請在您的問題中添加完整的錯誤。 –

+0

爲什麼不爲exe使用連接路徑呢? – jpmc26