1

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.

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks C.B! I just found another question stackoverflow.com/questions/8128276/… which is related to my question. Thanks for your help!
@Yousui Glad to help! Separing command and arguments in this way is more easy to manage in eventually foraech loop in scripts.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.