powershell - Powershell invoke-expression问题

标签 powershell

我有一个使用7z提取文件的命令,它可以在DOS命令行中使用。该命令是:

"C:\Documents and Settings\e.DEV\My Documents\7z.exe" x -o"C:\Documents and Settings\e.DEV\My Documents\utils" "C:\Documents and Settings\e.DEV\My Documents\rsasecureidtoken411.zip"

现在,我必须在powershell中运行上层命令,我使用call operator&调用它(在Powershell命令行中),但是似乎存在一些错误。当我按Enter键时,它仅在下一行显示>>,并且必须按Ctrl + c停止命令。
PS C:\> & "C:\Documents and Settings\e.DEV\My Documents\7z.exe" x -o"C:\Documents and Settings\e.DEV\My Documents\utils" "C:\Documents and Settings\e.DEV\My Documents\RSASecurIDToken411.zip"
>>
>>
>>
>>
>>
>>
PS C:\>

我也尝试过invoke-expression,但仍然无法正常工作。有人可以帮忙吗?

谢谢。

最佳答案

试试这个:

[string]$pathToZipExe = "C:\Documents and Settings\e.DEV\My Documents\7z.exe"
[Array]$arguments = "x", "-oC:\Documents and Settings\e.DEV\My Documents\utils", "C:\Documents and Settings\e.DEV\My Documents\RSASecurIDToken411.zip"

& $pathToZipExe $arguments

关于powershell - Powershell invoke-expression问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14663672/

相关文章:

python - 如何更改 Powershell 中的路径?

powershell - CSV 文件的 Add-Member 输出是 System.Object[]

com - 有什么方法可以终止 Powershell 中的挂起进程吗?

PowerShell WebRequest POST

powershell - 新的 AzResourceGroupDeployment : Cannot retrieve the dynamic parameters for the cmdlet

powershell - AWS Cli - 使用 powershell 中的环境变量查询输出

powershell - PowerShell : Capturing Error for [IO.File]::ReadAllText

powershell - Get-ChildItem:仅显示不包含特定文件的文件夹

Powershell:如何找出哪些正在运行的服务不是操作系统和非 MS 的一部分

csv - Powershell - 通过 'file name' 查找文件并根据 CSV 重命名