<?xml version="1.0" ?>
<package>
   <job id="postImage">
    <script language="JScript">
     <![CDATA[
        var oShell = new ActiveXObject("wscript.shell");
        var javaHome = oShell.ExpandEnvironmentStrings("%JAVA_HOME%");
        var javaExe = javaHome + "\\bin\\java.exe";
        var javawExe = javaHome + "\\bin\\javaw.exe";

        var oFSO = new ActiveXObject("Scripting.FileSystemObject");
        var oFolder = oFSO.getFolder(".");
        var imageHome = oFolder.path + "\\Corda DemoBench";
        var jreHome = imageHome + "\\runtime";
        var to = jreHome + "\\bin";
        if (!oFSO.FolderExists(to)) {
          oFSO.CreateFolder(to);
        }
        to += "\\";

        oFSO.CopyFile(javaExe, to);
        oFSO.CopyFile(javawExe, to);

        var bugfixDir = imageHome + "\\app\\bugfixes";
        var apply = bugfixDir + "\\apply.bat";
        if (oFSO.FileExists(apply)) {
            var errorCode = oShell.Run("\"" + apply + "\" \"" + jreHome + "\\lib\\rt.jar\"", 0, true);
            if (errorCode == 0) {
                oFSO.DeleteFolder(bugfixDir, true);
            } else {
                // Failed to apply bugfixes to rt.jar
                WScript.Quit(errorCode);
            }
        }
     ]]>
    </script>
   </job>
</package>
