Sign in to follow this  
Followers 0
carpediem

Unzupping and copying with flags

6 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Anyone that have gotten the flags to work?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Nice code.

I get the overwrite prompt on my XP SP2 box.


My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

Wierd... Why is 2003 server and XP SP2 act different on this? Anyone have a clue?

I already saw the other topic, but that does not cover flags at all.

Share this post


Link to post
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
Sign in to follow this  
Followers 0