Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to execute something like

7za e $file_path -oC:\Destination

inside a powershell script, but substitute destination folder (C:\Destination) with a variable. Some like:

7za e $file_path -o$output_path

which obviously does not work. The previous statement in fact creates a folder with actual name $output_path

How can this be done?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I think this should work, but it doesn't for me for some reason:

7za e $file_path -o$($output_path)

This will work:

$outparam = "-o" + $output_path
7za e $file_path $outparam

This will also work (it's just condensing the previous one into one line):

7za e $file_path $("-o" + $output_path)
share|improve this answer
    
Thanks! That also works -> & 7za e $file_path "-o${output_path}". I just needed those quotes. –  lalibi Mar 10 '12 at 11:55

I found a solution to overcome this but I would still like to now if there any other way to do it.

Push-Location ($output_path)
& 7za e $file_path
Pop-Location
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.