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