Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .