0

I am using Powershell v2 to run wzunzip.exe to unzip two zip files and move them into a temporary directory. This is what I have so far ...

$unzip = & 'C:\Program Files\pathTo\wzunzip.exe'
$unzip_src = Join-Path $pathTo "p17694377_121020_MSWIN-x86-64_1of8.zip"
$unzip_dst = $pathToDst

iex "$unzip -min -d $unzip_src2 $unzip_dst"

First off the help menu pops up upon execution, which I don't want, then this error

The term 'WinZip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that path is correct and try again.

I am not sure why I am getting the help menu since I am passing the -min parameter. I think if I can block the help menu my error might go away.

Also I have not added any code to unzip the two files I will need, till I can successfully unzip one of them.

Any ideas?

Hemi81
  • 578
  • 2
  • 15
  • 34
  • `& 'C:\Program Files\pathTo\wzunzip.exe'` would execute `wzunzip.exe` right there in the first line of your script. Are you sure this is what you want? – n0rd Sep 02 '15 at 18:53
  • I would assume that I would have to run the wzunzip.exe first to unzip the file, correct? – Hemi81 Sep 02 '15 at 18:56
  • You want to run `wzunzip.exe` passing it some arguments (the name of the zip file to unzip, i.e. what your fourth line does). Your first line actually just runs `wzunzip.exe` right there without any arguments and puts that program output into `$unzip` variable. – n0rd Sep 02 '15 at 19:49
  • the proper syntax for `iex` is `iex $command $arguments` correct? Should I consider Start-Process instead? – Hemi81 Sep 03 '15 at 13:20
  • What I am talking about is not related to `iex` at all. `&` is a call operator and will execute its argument right away. You don't have to use neither `iex` nor `Start-Process` unless you want to do something non-trivial. – n0rd Sep 03 '15 at 17:30

2 Answers2

2

I figured it out ...

Start-Process -filepath "S:\Program Files\winzip\wzunzip.exe" -ArgumentList "-d $unzip_src $unzip_dst"

Using Start-Process I was successfully able to unzip the file to the designated location. I get another popup window when unzipping, but I know there are additional parameters I can add to stop the popup window from appearing.

Thanks everyone for the help!

Hemi81
  • 578
  • 2
  • 15
  • 34
1

Try this way:

$unzip = '"c:\program files\winzip\wzunzip.exe"'
$test_path = 'C:\Users\user\Desktop'
$unzip_src = "`"$test_path\test.zip`""
$unzip_dst = "`"$test_path\test_unzipped`""
$command = "$unzip -e -d $unzip_src $unzip_dst"

iex "& $command"
Dmitry VS
  • 605
  • 5
  • 14
  • it seems when I separate `&` from `'"c:\program files\winzip\wzunzip.exe"'` I get and error because it can't read the white space between the `program` and `files` in `c:\program files`. If i use "`" to inclose my arguments I also can't run the program because the syntax is incorrect. – Hemi81 Sep 03 '15 at 13:16