Using Robocopy in WPKG
RoboCopy allows you to copy files in restartable mode. If the copying process or network connection dies it will start where it left off instead of starting over and copying the entire file.
Note that RoboCopy exit codes 0-3 are all success codes (http://ss64.com/nt/robocopy-exit.html).
WPKG has a bug that stalls wpkg.js if the command outputs too much text. RoboCopy tends to output a lot of text even when copying small files and RoboCopy doesn't have a silent flag so you have to use 5 different flags to disable all of the output.
An example install command looks like this:
<install cmd='%COMSPEC% /c robocopy /Z /NP /NDL /NFL /NJH /NJS "%Software%\7-Zip" "%Temp%\7-Zip" "7z%FileVersion%.msi"' > <exit code='0' /> <exit code='1' /> <exit code='2' /> <exit code='3' /> </install>
or this if you want to copy the entire folder:
<install cmd='%COMSPEC% /c robocopy /Z /S /NP /NDL /NFL /NJH /NJS "%Software%\7-Zip" "%Temp%\7-Zip"' > <exit code='0' /> <exit code='1' /> <exit code='2' /> <exit code='3' /> </install>
Useful flags while copying: (more available here http://ss64.com/nt/robocopy.html)
/Z : Copy files in restartable mode (survive network glitch). /S : Copy Subfolders. /E : Copy Subfolders, including Empty Subfolders. /PURGE : Delete dest files/folders that no longer exist in source. /MIR : MIRror a directory tree - equivalent to /PURGE plus all subfolders (/E)
/NP : No Progress - don't display % copied. /NDL : No Directory List - don't log directory names. /NFL : No File List - don't log file names. /NJH : No Job Header. /NJS : No Job Summary.
Alternative way to disable output:
/LOG:filename : Output status to LOG file (overwrite existing log).
This outputs the text to the log file instead of STDOUT which avoids the bug in WPKG.
Second Alternative way to disable output:
/LOG:nul : Output status to virtual LOG file NUL (equal to UNIX /dev/null).
This outputs the text to nothing instead of STDOUT which avoids the bug in WPKG.