0

I have some powershell code that calls WinZip and makes an archive.

$program = "c:\program files (x86)\WinZip\WZZIP.EXE"

& $program -a -P -r c:\temp\test.zip ("\\server.domain.com\FirstName LastName\ProjectId\*.*")

The two backslashes are part of a UNC path. I must use UNC and a fully qualified domain name.

The above code attempts to run but hangs until I kill it (press the stop button in ISE).

When I wrap the UNC path in parenthesis, again the code attempts to run but hangs.

How do I fix this? I'm stuck with UNC paths and using WinZip.

2
  • If the code is hanging, it's most likely a problem with WinZip. Why are you forced to use WinZip? I would strongly recommend using 7-Zip instead. Commented Aug 20, 2014 at 19:02
  • possible duplicate of How do I run my Winzip command line statement from within PowerShell? Commented Aug 20, 2014 at 19:13

2 Answers 2

1

UNC paths are not supported in WinZip from the command line. You will need to map a drive letter to the UNC path before preforming the zip. You can easily script this:

net use s: "\\server.domain.com\FirstName LastName\ProjectId\"

Alternatively, you can copy the files locally, zip them, then delete them from the local copy leaving only your zip file.

I believe 7zip does not have this limitation and is generally capable of doing everything WinZip is and more.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm not sure if "not supported" means "not officially supported, but it may work for you" or it will not work but I'm currently running the above command from a command line and the archive is being built just fine. I'm using WinZip 15.5 Pro (9468) with Winzip Command Line Support Add-On Version 4.0 32-bit (Build 10562)
It means everything I have found in researching this problem indicates it is not supported. Furthermore, there is no mention of support from WinZip: kb.winzip.com/kb/search/?s=1&q=unc&sb=Go
1

While not a direct answer to your question, perhaps you could use the PowerShell module PowerShellZIP at CodePlex (http://powershellzip.codeplex.com/) to create the ZIP files for you.

Then you can use the full powershell pipeline to create the ZIP files rather than calling out to WinZip.

I haven't tested to see if this module can zip files from an UNC path tho..

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.