diff --git a/src/configure.in b/src/configure.in
index 312dc3756d308a7b58ffbefd30b89e2b8d510020..0f464cd73e2bf12e8cd197ce7c801475048408e4 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1,4 +1,4 @@
-AC_REVISION("$Id: configure.in,v 1.1066 2008/07/21 18:14:06 mast Exp $")
+AC_REVISION("$Id: configure.in,v 1.1067 2008/07/31 18:01:48 mast Exp $")
 AC_INIT(interpret.c)
 AC_CONFIG_HEADER(machine.h)
 
@@ -2392,7 +2392,7 @@ if test "x$PIKE_PATH_TRANSLATE" = "x"; then
     # MinGW system.
     cat <<\EOF
 #!/bin/sh
-# Automatically generated by $Id: configure.in,v 1.1066 2008/07/21 18:14:06 mast Exp $.
+# Automatically generated by $Id: configure.in,v 1.1067 2008/07/31 18:01:48 mast Exp $.
 # MinGW-version. Do NOT edit.
 posix_name="`cat`"
 posix_prefix="/"
@@ -2430,7 +2430,7 @@ EOF
     # Native POSIX system.
   cat <<\EOF
 #!/bin/sh
-# Automatically generated by $Id: configure.in,v 1.1066 2008/07/21 18:14:06 mast Exp $.
+# Automatically generated by $Id: configure.in,v 1.1067 2008/07/31 18:01:48 mast Exp $.
 # POSIX-version. Do NOT edit.
 cat
 EOF
@@ -2439,7 +2439,7 @@ else
   # rntcl-style
   cat <<\EOF
 #!/bin/sh
-# Automatically generated by $Id: configure.in,v 1.1066 2008/07/21 18:14:06 mast Exp $.
+# Automatically generated by $Id: configure.in,v 1.1067 2008/07/31 18:01:48 mast Exp $.
 # RNTCL-version. Do NOT edit.
 sed -e "$PIKE_PATH_TRANSLATE"
 EOF
@@ -4453,6 +4453,7 @@ AC_CHECK_FUNCS( \
  GetSystemInfo \
  clock_getcpuclockid \
  backtrace \
+ SetErrorMode \
 )
 
 # SunOS 4 realloc() returns NULL when reallocing NULL.
diff --git a/src/main.c b/src/main.c
index 41a37b550e7d89186e9f5a46848c212a21fffdc5..ef384f60fc83db3927ff84e7f049425feee9bd27 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: main.c,v 1.231 2008/06/29 10:40:55 mast Exp $
+|| $Id: main.c,v 1.232 2008/07/31 18:01:48 mast Exp $
 */
 
 #include "global.h"
@@ -468,6 +468,12 @@ int main(int argc, char **argv)
 	    p++;
 	    goto more_r_flags;
 
+	  case 'l':
+	    set_pike_runtime_options (RUNTIME_ERROR_DIALOGS,
+				      RUNTIME_ERROR_DIALOGS);
+	    p++;
+	    goto more_d_flags;
+
          default:
             p++;
 	    break;
@@ -539,6 +545,24 @@ int main(int argc, char **argv)
   if (d_flag)
     set_pike_debug_options(ERRORCHECK_MUTEXES, ERRORCHECK_MUTEXES);
 
+#ifdef HAVE_SETERRORMODE
+  if (!(runtime_options & RUNTIME_ERROR_DIALOGS)) {
+    /* This avoids popups when LoadLibrary fails to find a dll.
+     *
+     * Note that the popup is the _only_ way to see which dll (loaded
+     * indirectly by dependencies from the one in the LoadLibrary
+     * call) that Windows didn't find. :( Hence the -rl runtime option
+     * to turn it on.
+     *
+     * Note: This setting is process global. */
+    SetErrorMode (SEM_FAILCRITICALERRORS |
+		  /* Maybe set this too? Don't know exactly when it
+		   * has effect. /mast */
+		  /*SEM_NOOPENFILEERRORBOX | */
+		  GetErrorMode());
+  }
+#endif
+
   init_pike_runtime(exit);
 
   /* NOTE: Reuse master_location here to avoid duplicates of
diff --git a/src/pike_embed.h b/src/pike_embed.h
index 9c9aaeee4b2e2cd974009f4db0723adea908dfc2..243a23f48f9976a319c74c9c24a911318e55705b 100644
--- a/src/pike_embed.h
+++ b/src/pike_embed.h
@@ -1,5 +1,5 @@
 /*
- * $Id: pike_embed.h,v 1.10 2008/06/05 15:12:44 mast Exp $
+ * $Id: pike_embed.h,v 1.11 2008/07/31 18:01:49 mast Exp $
  *
  * Pike embedding API.
  *
@@ -33,8 +33,9 @@ extern int yydebug;
 int set_pike_debug_options(int bits, int mask);
 
 /* Runtime options */
-#define RUNTIME_CHECK_TYPES  1
-#define RUNTIME_STRICT_TYPES 2
+#define RUNTIME_CHECK_TYPES	1
+#define RUNTIME_STRICT_TYPES	2
+#define RUNTIME_ERROR_DIALOGS	4
 
 int set_pike_runtime_options(int bits, int mask);