Hemi81
Hemi81

Reputation: 588

Winzip in Powershell

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?

Upvotes: 0

Views: 6442

Answers (2)

Hemi81
Hemi81

Reputation: 588

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!

Upvotes: 2

Dmitry VS
Dmitry VS

Reputation: 615

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"

Upvotes: 1

Related Questions