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:
Function GUICopy($sSrc, $sDest, OPTIONAL $lFlags, OPTIONAL $bMove)
Dim $sVer,$objShell,$objFldr
If Not Exist($sSrc) Exit 2 Endif
If Not Exist($sDest) Exit 3 Endif
If @INWIN=1
$sVer=GetFileVersion(%WINDIR%+"\System32\Shell32.dll","FileVersion")
Else
$sVer=GetFileVersion(%WINDIR%+"\System\Shell32.dll","FileVersion")
Endif
If $sVer<"4.71" Exit 10 Endif
$objShell=CreateObject("Shell.Application")
$objFldr=$objShell.NameSpace($sDest)
If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
Select
Case $bMove=1 $objFldr.MoveHere($sSrc,$lFlags)
Case $bMove=0 $objFldr.CopyHere($sSrc,$lFlags)
Case 1 Exit 87
EndSelect
If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
Exit @ERROR
EndFunction
If at first you fail, call it version 1.0
No comments:
Post a Comment