--- config_office/configure.in
+++ config_office/configure.in
@@ -5242,6 +5242,32 @@
 
 AC_SUBST(BUILD_TYPE)
 
+if test "$_os" = "WINNT"; then
+    # Set TMP (and TEMP) to a short value to avoid potential problems with
+    # too long lines in ddf files
+    AC_MSG_CHECKING([for problematic length of TMP and TEMP])
+    # $TMP and $TEMP are usually the same, but just to be sure...
+    # and I am not sure which one actually gets used
+    case "`cygpath -w $TMP`!`cygpath -w $TEMP`" in
+    ??????????*!*|*!????????*)
+	# Either is "long", try using "C:\tmp"
+	AC_MSG_RESULT([yes])
+	mkdir /cygdrive/c/tmp 2>/dev/null
+	if test -d /cygdrive/c/tmp && touch /cygdrive/c/tmp/foobarzap 2>/dev/null; then
+	    rm /cygdrive/c/tmp/foobarzap
+	    TEMPORARY_DIRECTORY=/cygdrive/c/tmp
+	    AC_SUBST(TEMPORARY_DIRECTORY)
+	    echo Using `cygpath -w $TEMPORARY_DIRECTORY`
+	else
+	    AC_MSG_WARN([One or both are too long, but can't figure out what to use instead])
+	fi
+	;;
+   *)
+	AC_MSG_RESULT([no])
+	;;
+    esac
+fi
+
 # make sure config.guess is +x; we execute config.guess, so it has to be so; 
 chmod +x $_solenv/bin/config.guess
 
dummy line to avoid confusing diff-mode
--- config_office/set_soenv.in
+++ config_office/set_soenv.in
@@ -1660,6 +1660,10 @@
    ToFile( "ENABLE_VCTK",       "@ENABLE_VCTK@",    "e" );
    ToFile( "NETTOOLKIT",        "@NETTOOLKIT@",     "e" );
    ToFile( "USE_NEW_SDK",       $USE_NEW_SDK,       "e" );
+   if( '@TEMPORARY_DIRECTORY@' ) {
+      ToFile( "TMP",            "@TEMPORARY_DIRECTORY@", "e");
+      ToFile( "TEMP",           "@TEMPORARY_DIRECTORY@", "e");
+   }
 }
 ToFile( "PERL",              $PERL,              "e" );
 ToFile( "RPM",               "@RPM@",            "e" );
