diff --git a/src/portable.cpp b/src/portable.cpp
index 258c50f..3f27cb8 100644
--- a/src/portable.cpp
+++ b/src/portable.cpp
@@ -169,10 +169,16 @@ int portable_system(const char *command,const char *args,bool commandHasConsole)
     else if (sInfo.hProcess)      /* executable was launched, wait for it to finish */
     {
       WaitForSingleObject(sInfo.hProcess,INFINITE); 
-      CloseHandle(sInfo.hProcess);
+	  /* get process exit code */
+	  DWORD exitCode;
+	  if (!GetExitCodeProcess(sInfo.hProcess,&exitCode))
+	  {
+		  exitCode = -1;
+	  }
+	  CloseHandle(sInfo.hProcess);
+	  return exitCode;
     }
   }
-  return 0;
 #endif
 
 }