Hello,
I have a problem already addressed unsuccessfully in this newsgroup,
but I'll try anyway.

The following script (derived from another script published in this
group) is supposed to extract a ZIP file to a temp folder and run a
predefined installer, but the CopyHere method seems to ignore the
FOF_NOCONFIRMATION and/or FOF_NOCONFIRMDIRCREATE options (in the last
part of the script), as the file overwrite confirmation dialog keeps
appearing.

Could it be that CopyHere is fooled by the use of the Items method to
enumerate the contents of the zip file?
I'm looking for alternative solutions, but I cannot make use of any
plugin, like a Winzip command line utility.

Thank you,
/_urka


Option Explicit

Dim WshShell, FS, SA, TempFolder, FilesInZip, PathToZipFile

Const ZipFile = "\zipfile.zip"
Const FileToRun = "installer.vbe"
Const Params = "/S /L"
Const Dest = "\whatever"

Const FOF_NOCONFIRMATION = 16
Const FOF_NOCONFIRMDIRCREATE = 512

'===================================================================
'Retrieves the current directory to create the full path to zip file
'===================================================================
Set WshShell = CreateObject("WScript.Shell")
PathToZipFile = WshShell.CurrentDirectory & ZipFile
WScript.Echo "The zip file is in " & PathToZipFile & VBCRLF _
& "Click OK to proceed with the installation"

'==================================================
'Creates a folder to extract the zip contents into
'==================================================
Set FS = CreateObject("Scripting.FileSystemObject")
TempFolder = FS.GetSpecialFolder(2) & Dest
If FS.FolderExists(TempFolder) = False Then
FS.CreateFolder(FS.GetSpecialFolder(2) & Dest)
End If

'==========================================================================
'Extracts the zip contents into TempFolder overwriting without
confirmation
'and launches the installer with the assigned parameters
'==========================================================================
Set SA = CreateObject("Shell.Application")
Set FilesInZip = SA.NameSpace(PathToZipFile).Items
SA.NameSpace(TempFolder).CopyHere FilesInZip, FOF_NOCONFIRMATION +
FOF_NOCONFIRMDIRCREATE
SA.ShellExecute FileToRun, Params, TempFolder

Re: CopyHere keeps asking for overwrite confirmation by Alexander

Alexander
Fri Aug 31 09:52:32 PDT 2007

31.08.2007 15:24, Lurka schrieb:

> The following script is supposed to extract a ZIP file to a temp folder and run a
> predefined installer, but the CopyHere method seems to ignore the
> FOF_NOCONFIRMATION and/or FOF_NOCONFIRMDIRCREATE options (in the last
> part of the script), as the file overwrite confirmation dialog keeps
> appearing.
>
> Could it be that CopyHere is fooled by the use of the Items method to
> enumerate the contents of the zip file?
> I'm looking for alternative solutions, but I cannot make use of any
> plugin, like a Winzip command line utility.

It's simply a bug, that will probably never get fixed.

You need a different API/Tool. If you can't install/copy/rely on
3rd party tools then your probably stuck.
Afaics the zipfldr.dll doesn't even expose a Win32-API for (un)zipping
for coypright reasons.

MfG,
Alex



Re: CopyHere keeps asking for overwrite confirmation by Ayush

Ayush
Fri Aug 31 16:24:04 PDT 2007

[Lurka] wrote-:
> Hello,
> I have a problem already addressed unsuccessfully in this newsgroup,
> but I'll try anyway.

> The following script (derived from another script published in this
> group) is supposed to extract a ZIP file to a temp folder and run a
> predefined installer, but the CopyHere method seems to ignore the
> FOF_NOCONFIRMATION and/or FOF_NOCONFIRMDIRCREATE options (in the last
> part of the script), as the file overwrite confirmation dialog keeps
> appearing.

> Could it be that CopyHere is fooled by the use of the Items method to
> enumerate the contents of the zip file?
> I'm looking for alternative solutions, but I cannot make use of any
> plugin, like a Winzip command line utility.

Delete the TempFolder before copying.

Good Luck, Ayush.
--
Scripting Solutions Center : http://snipurl.com/Scripting_Solutions