【发布时间】:2013-07-09 11:33:19
【问题描述】:
我编写了一个带有 bool 参数的 powershell 脚本 我也有这个 powershell 脚本的 windows 快捷方式。 问题是每当我尝试从快捷方式运行脚本时,参数都会被解释为字符串,而不是布尔值,并且脚本会崩溃。
这是我最初放在快捷方式目标部分下的内容:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" $true
我已经在网上搜索了解决方案并尝试了以下选项:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" -copyAll:$true
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" -copyAll:`$$true
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" "`$$true"
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File "C:\Program Files\MySoftware\diagnostic\DiagnosticTool.ps1" `$$true
还有多种这样的变化。
这是我的问题:当从 Windows 快捷方式运行 a 时,有没有办法将 bool 参数的值发送到脚本?
【问题讨论】:
标签: powershell parameters boolean shortcut