Showing posts with label Kixtart Copy. Show all posts
Showing posts with label Kixtart Copy. Show all posts

Tuesday, June 26, 2007

Kix Copy script with GUI (Kixtart UDF)

Another KIXtart UDF, well the title says it all...

Dependencies:
KiX 4.02 (or higher)
Shell32.dll version 4.71 or later. (Included with: Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0.)

Usage:
GUICopy("source", "destination", "optional flag", "optional flag")
@ERROR " : " @SERROR ?

Optional Flags:
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.
8192 - Version 5.0. Do not copy connected files as a group. Only copy the
specified files.


Returns The exitcode of the command in the @ERROR macro.
@ERROR = 0 The operation completed successfully.
@ERROR = 2 The system cannot find the file specified. (Refers to Source file.)
@ERROR = 3 The system cannot find the path specified. (Bad destination path.)
@ERROR = 9 The storage control block address is invalid. (Most likely cancelled copy.)
@ERROR = 10 The environment is incorrect. (Incorrect Shell32.dll version.)
@ERROR = 87 The parameter is incorrect. (Use 0 or 1 to specify Copy or Move.)

Code Snippet:

  1. Function GUICopy($sSrc, $sDest, OPTIONAL $lFlags, OPTIONAL $bMove)
  2. Dim $sVer,$objShell,$objFldr
  3. If Not Exist($sSrc) Exit 2 Endif
  4. If Not Exist($sDest) Exit 3 Endif
  5. If @INWIN=1
  6. $sVer=GetFileVersion(%WINDIR%+"\System32\Shell32.dll","FileVersion")
  7. Else
  8. $sVer=GetFileVersion(%WINDIR%+"\System\Shell32.dll","FileVersion")
  9. Endif
  10. If $sVer<"4.71" Exit 10 Endif
  11. $objShell=CreateObject("Shell.Application")
  12. $objFldr=$objShell.NameSpace($sDest)
  13. If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
  14. Select
  15. Case $bMove=1 $objFldr.MoveHere($sSrc,$lFlags)
  16. Case $bMove=0 $objFldr.CopyHere($sSrc,$lFlags)
  17. Case 1 Exit 87
  18. EndSelect
  19. If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
  20. Exit @ERROR
  21. EndFunction

If at first you fail, call it version 1.0