1.

Solve : How do I disable warning promts when overwirting files with vbscript??

Answer»

I have written a script that extracts the files from a zip file, that dorps into an applications main folder, thus upgrading the folder with new zip file have some same folders . The script works, however when it shows the warning propmt (confirm replace file) Instead of the user having to click (Yes to all) is there a way that I can set that to not appear and the extraction just happen WITHOUT a confirmation prompt. Messages like that can scare users and they may not be paying attention to it and hit cancel then the upgrade wont happen. PLEASE HELP Smiley



Option Explicit
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
dim msg
msg = msgbox("Please WAIT while We Install Upgraded Components Once complete you will be prompted to restart")

'Zip Extraction sub
Sub Extract( ByVal myZipFile, ByVal myTargetDir )
Dim intOptions, objShell, objSource, objTarget


' Create the REQUIRED Shell objects
Set objShell = CreateObject( "Shell.Application" )

' Create a reference to the files and folders in the ZIP file
Set objSource = objShell.NameSpace( myZipFile ).Items( )

' Create a reference to the target folder
Set objTarget = objShell.NameSpace( myTargetDir )



' UnZIP the files
objTarget.CopyHere objSource, intOptions

' Release the objects
Set objSource = Nothing
Set objTarget = Nothing
Set objShell = Nothing
End Sub

'Extract the Zip file into Directory
Extract "\myfile.zip", "C:\Program Files\Desitnation"
You have a variable (intOptions) that you never set.

The following table should help you out:

Quote

' 4: Do not display a progress dialog box.
' 8: Give the file a new name in a move, copy, or rename
' operation if a file with the target name already exists.
' 16: Click "Yes to All" in any dialog box that is displayed.
' 64: Preserve UNDO information, if possible.
' 128: Perform the operation on files only if a wildcard file
' name (*.*) is specified.
' 256: Display a progress dialog box but do not show the file
' names.
' 512: Do not confirm the creation of a new directory if the
' operation requires one to be created.
' 1024: Do not display a user INTERFACE if an error occurs.
' 4096: Only operate in the local directory.
' Don't operate recursively into subdirectories.
' 9182: Do not copy connected files as a group.
' Only copy the specified files.

Hope this helps.


Discussion

No Comment Found