-wimlib-imagex capture in.dir test.wim --norpfix > NUL\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
-wimlib-imagex apply test.wim out.dir > NUL\r
-if %errorlevel% neq 0 exit /b %errorlevel%\r
-win32-tree-cmp in.dir out.dir\r
-if %errorlevel% neq 0 (\r
- echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
- echo TEST FAILED!!!!!!!\r
- echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
- exit /b %errorlevel%\r
-)\r
-\r
-REM Fun fact: There are bugs in Microsoft's imagex.exe that make it fail some\r
-REM of our tests.\r
-REM\r
-REM rd /S /Q out.dir\r
-REM md out.dir\r
-REM imagex /capture in.dir test.wim "test" /norpfix > nul\r
-REM if %errorlevel% neq 0 exit /b %errorlevel%\r
-REM imagex /apply test.wim 1 out.dir > nul\r
-REM if %errorlevel% neq 0 exit /b %errorlevel%\r
-REM win32-tree-cmp in.dir out.dir\r
-REM if %errorlevel% neq 0 (\r
- REM echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
- REM echo TEST FAILED!!!!!!! ^(imagex^)\r
- REM echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
- REM exit /b %errorlevel%\r
-REM )\r
+%WIMLIB_IMAGEX% capture in.dir test.wim --norpfix > NUL\r
+if %errorlevel% neq 0 goto :fail\r
+%WIMLIB_IMAGEX% apply test.wim out.dir > NUL\r
+if %errorlevel% neq 0 goto :fail\r
+%WIN32_TREE_CMP% in.dir out.dir\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+REM apply a second time so we test the case where the files already exist\r
+%WIMLIB_IMAGEX% apply test.wim out.dir > NUL\r
+if %errorlevel% neq 0 goto :fail\r
+%WIN32_TREE_CMP% in.dir out.dir\r
+if %errorlevel% neq 0 goto :fail\r
+\r
+REM Fun fact: Microsoft's WIMGAPI has bugs that make it fail some of our tests.\r
+REM Even the Windows 8.1 version has incorrect behavior with empty files with\r
+REM multiple links, or files with named data streams and multiple links.\r
+rd /S /Q out.dir\r
+md out.dir\r
+REM dism /capture-image /capturedir:in.dir /imagefile:test.wim /name:"test" /norpfix > nul\r
+REM if %errorlevel% neq 0 goto :fail\r
+dism /apply-image /imagefile:test.wim /index:1 /applydir:out.dir > nul\r
+if %errorlevel% neq 0 goto :fail\r
+%WIN32_TREE_CMP% in.dir out.dir\r