【发布时间】:2018-10-22 15:34:25
【问题描述】:
我编写了一个 PowerShell 脚本来执行带有空格的 exe,但它一直失败,没有读取完整路径。
$now = Get-Date -format "MM_dd_yyyy"
$onepath ="C:\Program Files (x86)\GoFileRoom\IWMUploadDocuments\logs\"
$scpath = "F:\Program Files\NSClient++\scripts\"
$onefile = "IWMUploadDocumentsLog$now.txt"
$script = "check_log3.exe"
& "$scpath$script" -p "Error Logging into GFR" -l "$onepath$onefile" -c 1
Write-Output "$onepath$onefile"
这是输出:
PS C:\Windows\system32> F:\Program Files\NSClient++\scripts\onesource.ps1 无法读取“C:\Program” C:\Program Files (x86)\GoFileRoom\IWMUploadDocuments\logs\IWMUploadDocumentsLog10_22_2018.txt【问题讨论】:
-
尝试使用内撇号˙"'$onepath$onefile'"˙ 或双引号作为
"""""$onepath$onefile"""""
标签: powershell spaces