diff --git a/contrib/win32/hg.bat b/contrib/win32/hg.bat
index 769027075e2183799e40bfad188df80cf4de40ae_Y29udHJpYi93aW4zMi9oZy5iYXQ=..975c4fc4a51295247fa46323b74cedb7dc989b24_Y29udHJpYi93aW4zMi9oZy5iYXQ= 100644
--- a/contrib/win32/hg.bat
+++ b/contrib/win32/hg.bat
@@ -15,3 +15,5 @@
     python "%~dp0hg" %*
 )
 endlocal
+
+exit /b %ERRORLEVEL%
diff --git a/tests/test-alias.t b/tests/test-alias.t
index 769027075e2183799e40bfad188df80cf4de40ae_dGVzdHMvdGVzdC1hbGlhcy50..975c4fc4a51295247fa46323b74cedb7dc989b24_dGVzdHMvdGVzdC1hbGlhcy50 100644
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -525,3 +525,12 @@
   [1]
   $ hg exit1
   [1]
+
+#if no-outer-repo
+  $ hg root
+  abort: no repository found in '$TESTTMP' (.hg not found)!
+  [255]
+  $ hg --config alias.hgroot='!hg root' hgroot
+  abort: no repository found in '$TESTTMP' (.hg not found)!
+  [255]
+#endif