bod*_*ydo 7 powershell command-prompt
我们的IT部门正在转向Windows 8,每个人都开始使用PowerShell作为他们的默认Windows命令行环境,而不是cmd.exe.
不幸的是,PowerShell会评估您在其中键入的内容,并且很难将原始命令行参数传递给程序.
例如,我有一个程序inventory.exe,它采用一个特殊的字符串来格式化其输出.我无法在PowerShell中传递这个特殊字符串,因为我收到一个神秘的错误:
PS C:\Users\Administrator> inventory.exe 'inventory "," date "," owner'
inventory.exe error: No comma allowed
Run Code Online (Sandbox Code Playgroud)
我假设PowerShell 'inventory "," date "," owner'以某种方式评估了字符串,并将其他内容传递给inventory.exe程序,因此它打印出错误.
这个程序适用于cmd.exe:
C:\Documents and Settings\boda> inventory.exe 'inventory "," date "," owner'
... (the output that I expect) ...
Run Code Online (Sandbox Code Playgroud)
它即使我键入的字符,如变得更糟%,$在PowerShell中.
有谁知道如何将原始字符串传递给PowerShell中的命令?
如果您使用的是Powershell v3.0,那么有一种新的语法可以让Powershell避免对参数进行任何额外的解析.就像是:
inventory.exe --% 'inventory', 'date', 'owner'
Run Code Online (Sandbox Code Playgroud)
这里提到的还有其他方法:http://blogs.technet.com/b/josebda/archive/2012/03/03/using-windows-powershell-to-run-old-command-line-tools-and-他们,最奇怪的,parameters.aspx
| 归档时间: |
|
| 查看次数: |
1830 次 |
| 最近记录: |