diff --git a/SystemTools.cxx b/SystemTools.cxx
index 87fdfbe2d3208783f7894ef54bb5fd9169a1131c..8a61267c923292a6ab74221c1dc8b85b141e7bc1 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -3536,6 +3536,16 @@ static int GetCasePathName(const kwsys_stl::string & pathIn,
     kwsys_stl::string test_str = casePath;
     test_str += path_components[idx];
 
+    // If path component contains wildcards, we skip matching
+    // because these filenames are not allowed on windows,
+    // and we do not want to match a different file.
+    if(path_components[idx].find('*') != kwsys_stl::string::npos ||
+       path_components[idx].find('?') != kwsys_stl::string::npos)
+      {
+      casePath = "";
+      return 0;
+      }
+
     WIN32_FIND_DATAW findData;
     HANDLE hFind = ::FindFirstFileW(Encoding::ToWide(test_str).c_str(),
       &findData);
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index a7cfa0de12c9becb8c4bf413dc8a444de328fcaf..b41532b114fca3e7697d8fe3055dbc74fe9bc53d 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -589,6 +589,28 @@ static bool CheckRelativePaths()
   return res;
 }
 
+static bool CheckCollapsePath(
+  const kwsys_stl::string& path,
+  const kwsys_stl::string& expected)
+{
+  kwsys_stl::string result = kwsys::SystemTools::CollapseFullPath(path);
+  if(expected != result)
+    {
+    kwsys_ios::cerr << "CollapseFullPath(" << path
+      << ")  yielded " << result << " instead of " << expected << kwsys_ios::endl;
+    return false;
+    }
+  return true;
+}
+
+static bool CheckCollapsePath()
+{
+  bool res = true;
+  res &= CheckCollapsePath("/usr/share/*", "/usr/share/*");
+  res &= CheckCollapsePath("C:/Windows/*", "C:/Windows/*");
+  return res;
+}
+
 //----------------------------------------------------------------------------
 int testSystemTools(int, char*[])
 {
@@ -622,5 +644,7 @@ int testSystemTools(int, char*[])
 
   res &= CheckRelativePaths();
 
+  res &= CheckCollapsePath();
+
   return res ? 0 : 1;
 }