diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm
index 9ca5b1f13ad39a496b20a5d3cf9e776e3e92bbd9..f99f5ea52f9c85c388a57f8396a021f510bed3d1 100644
--- a/src/tools/msvc/Project.pm
+++ b/src/tools/msvc/Project.pm
@@ -126,7 +126,8 @@ sub AddLibrary
 {
 	my ($self, $lib, $dbgsuffix) = @_;
 
-	if ($lib =~ m/\s/)
+	# quote lib name if it has spaces and isn't already quoted
+	if ($lib =~ m/\s/ && $lib !~ m/^[&]quot;/)
 	{
 		$lib = '"' . $lib . """;
 	}
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index cccc9df52576dc2bed0c7e5bcb536a2f8e338728..facf3489fb7fbc8e4803d41113da6aa0008d500b 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -133,8 +133,9 @@ sub GetOpenSSLVersion
 
 	# Attempt to get OpenSSL version and location.  This assumes that
 	# openssl.exe is in the specified directory.
+	# Quote the .exe name in case it has spaces
 	my $opensslcmd =
-	  $self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";
+	  qq("$self->{options}->{openssl}\\bin\\openssl.exe" version 2>&1);
 	my $sslout = `$opensslcmd`;
 
 	$? >> 8 == 0