Jump to content

Unzupping and copying with flags


Recommended Posts

EDIT: Can't seem to edit the topic... Unzipping is, of course, what I meant.

Hi!

Trying to copy some files from a zip archive using the CopyHere method.

Here's what Microsoft says about the method.

Folder.CopyHere(vItem [, vOptions])

vItem Required.

Specifies the item or items to copy. This can be a string that represents a file name, a FolderItem object, or a FolderItems object.

vOptions Optional. Specifies options for the copy operation. This value can be zero or a combination of the following values. These values are based upon flags defined for use with the fFlags member of the C++ SHFILEOPSTRUCT structure. These flags are not defined as such for Microsoft Visual Basic, Visual Basic Scripting Edition (VBScript), or Microsoft JScript, so you must define them yourself or use their numeric equivalents.4 Do not display a progress dialog box.

8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.

16 Respond with "Yes to All" for 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.

2048 Version 4.71. Do not copy the security attributes of the file.

4096 Only operate in the local directory. Don't operate recursively into subdirectories.

9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.

This is how my function looks like right now (no error checking and such yet. The problem I have is that I can't seem to get the flags working.

Func unzipIt($sPath,$dPath)
   $objShell = ObjCreate("Shell.Application");
   $SrcFldr = $objShell.NameSpace($sPath)
   $DestObj = $objShell.NameSpace($dPath)
   $FldrItems = $SrcFldr.Items
   $DestObj.CopyHere($FldrItems, 16)
EndFunc

the flag 16 is supposed to respond with a "yes to all" in case a file already exists, but the problem for me is that I still see the dialog to overwrite. Am I using the flags wrong, or is there a problem somewhere else?

Edited by carpediem
Link to comment
Share on other sites

Func unzipIt($sPath,$dPath)
   $objShell = ObjCreate("Shell.Application");
   $SrcFldr = $objShell.NameSpace($sPath)
   $DestObj = $objShell.NameSpace($dPath)
   $FldrItems = $SrcFldr.Items
   $DestObj.CopyHere($FldrItems, 16)
EndFunc

the flag 16 is supposed to respond with a "yes to all" in case a file already exists, but the problem for me is that I still see the dialog to overwrite. Am I using the flags wrong, or is there a problem somewhere else?

hmm... your code works fine on my Windows 2003 server. I don't get any dialog and if I delete option, i get confirmation dialog.

unzipIt("c:\test1","c:\test2")
Func unzipIt($sPath,$dPath)
   $objShell = ObjCreate("Shell.Application");
   $SrcFldr = $objShell.NameSpace($sPath)
   $DestObj = $objShell.NameSpace($dPath)
   $FldrItems = $SrcFldr.Items
   $DestObj.CopyHere($FldrItems,16)
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...