I have a command to extract a file using 7z and it works in a DOS command line. The command is:
"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"
Now I have to run the upper command in powershell, I use a call operator
& to call it (in Powershell command line), but it seems there are some errors with it. It just shows >> at the next line when I press enter, and I have to press Ctrl + c to stop the command.
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:\>
I've also tried invoke-expression
but still can't make it work. Anyone can help with it?
Thanks.
try this:
[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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.