You are not logged in.

#1 01 Mar 2012 16:39

spotless
Member
Registered: 01 Mar 2012
Posts: 1

How to Unzip(extract) without any other application?

Is there powershell itself method to unzip files?

I found this below in the web.

function UnZipMe($zipfilename,$destination) 
{ 
   $shellApplication = new-object -com shell.application 
   $zipPackage = $shellApplication.NameSpace($zipfilename) 
   $destinationFolder = $shellApplication.NameSpace($destination) 

# CopyHere vOptions Flag # 4 - Do not display a progress dialog box. 
# 16 - Respond with "Yes to All" for any dialog box that is displayed. 

$destinationFolder.CopyHere($zipPackage.Items(),20) 
} 

$a = gci -Path C:\inetpub\iislogs3.com\wwwlogs -Filter *.zip 

foreach($file in $a) 
{ 
    Write-Host "Processing - $file" UnZipMe –zipfilename 
    $file.FullName -destination $file.DirectoryName 
}

I tried this, but it doesn't work.
Do you have any other way to unzip? or correct this code?

Offline

#2 01 Mar 2012 20:40

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: How to Unzip(extract) without any other application?

This part

foreach($file in $a) 
{ 
    Write-Host "Processing - $file" UnZipMe –zipfilename 
    $file.FullName -destination $file.DirectoryName 
}

looks like it should be

foreach($file in $a) 
{ 
   Write-Host "Processing - $file"
   UnZipMe –zipfilename $file.FullName -destination $file.DirectoryName 
}

Also the code looks to me like it's dependent on the Windows Explorer support for zipFolders, which you may have turned off

Unregister (disable) XP Zip folders
REGSVR32 /u C:\Windows\System32\zipfldr.dll

Register (enable) XP Zip folders
REGSVR32 zipfldr.dll

http://ss64.com/nt/regsvr32.html

Offline

Board footer

Powered by