Index: tol/bbasic/sys.cpp
===================================================================
--- tol/bbasic/sys.cpp	(revision 5a1c98150d94c04703d7871426f7effdd7bb47cf)
+++ tol/bbasic/sys.cpp	(revision a94fd1cdb79c6eeb16c329460d160dc1ac8cb250)
@@ -381,4 +381,5 @@
 
 #ifndef UNIX
+
 //--------------------------------------------------------------------
 BBool BSys::WinExecuteFile(const BText& fileName)
@@ -435,5 +436,5 @@
 
 //--------------------------------------------------------------------
-  BBool BSys::WinSystem  (const BText& command, BInt showMode, bool wait)
+BBool BSys::WinSystem  (const BText& command, BInt showMode, bool wait)
 //--------------------------------------------------------------------
 {
@@ -493,5 +494,5 @@
       }
     }
-    else if(wait)
+    else if(wait) //(pgea) y esto ?
     {
       result=WaitForSingleObject(piProcInfo.hProcess, 0);
@@ -508,56 +509,118 @@
 }
 
-
-//--------------------------------------------------------------------
-//BBool BSys::WinSystem  (const BText& command, BInt showMode)
-
-/*! Windows operating system call.
- * /
-//--------------------------------------------------------------------
-{
-  BInt errNum = WinExec(command.String(),showMode);
-  
-  BBool err=(errNum<=31);
-  BText msg;
-  switch(errNum)
-  {
-    case 0:
+//--------------------------------------------------------------------
+BBool BSys::WinSystemQuiet(const BText& command, 
+                           BText& output, BText& error)
+//--------------------------------------------------------------------
+{
+  SetLastError(0);
+
+  SECURITY_ATTRIBUTES secattr; 
+  memset(&secattr, 0, sizeof(secattr));
+  secattr.nLength = sizeof(secattr);
+  secattr.bInheritHandle = TRUE;
+  HANDLE rPipe, wPipe, rPipeE, wPipeE;
+  CreatePipe(&rPipe,&wPipe,&secattr,0);
+  CreatePipe(&rPipeE,&wPipeE,&secattr,0);
+
+  STARTUPINFO sInfo; 
+  memset(&sInfo, 0, sizeof(sInfo));
+  PROCESS_INFORMATION pInfo; 
+  memset(&pInfo, 0, sizeof(pInfo));
+  sInfo.cb = sizeof(sInfo);
+  sInfo.dwFlags = STARTF_USESTDHANDLES; 
+  sInfo.hStdInput = NULL; 
+  sInfo.hStdOutput = wPipe; 
+  sInfo.hStdError = wPipeE;
+
+  BText cmdRedirected = BText("cmd /c ") + command;
+  char* cmd = (char*)cmdRedirected.String();
+
+  int result = 0;
+  bool ok = true; 
+
+  if (!CreateProcess(NULL, cmd, NULL, NULL,
+       TRUE, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, 
+       NULL, NULL, &sInfo, &pInfo))
+  {
+    error = I2("Creating process \n", 
+               "Creando el proceso \n") + command;
+    ok = false;
+  }
+  else
+  {
+    result = WaitForSingleObject(pInfo.hProcess, INFINITE);
+    if(result != WAIT_OBJECT_0)
     {
-      msg = I2("The system is out of memory or resources.",
-               "El sistema no tiene memoria o recursos");
-      break;
-    }
-    case ERROR_BAD_FORMAT:
+      error = I2("Waiting for result of process \n", 
+                 "Esperando el resultado del proceso \n") +  command;
+      ok = false;
+    }
+    else
     {
-      msg = I2("The .EXE file is invalid","El fichero .EXE no es válido.");
-      break;
-    }
-    case ERROR_FILE_NOT_FOUND:
-    {
-      msg = I2("The specified file was not found.",
-               "No se encuentra el fichero especificado");
-      break;
-    }
-    case ERROR_PATH_NOT_FOUND :
-    {
-      msg = I2("The specified path was not found.",
-               "No se encuentra el camino especificado.");
-    }
-  }
-  if(err)
-  {
-    Error(I2("Executing commad \n", "Ejecutando el comando \n") +
-              command + "\n" + msg);
-  }
-  return(!err);
-}
-*/
-
-#else
-
-
-#endif
-
-
+      CloseHandle(wPipe);
+      CloseHandle(wPipeE);
+
+      BChar buffer[128];
+      DWORD reDword;
+      BOOL res = false;
+      do {
+        res=::ReadFile(rPipe, buffer, 128, &reDword, 0);
+        output += BText(buffer,0,reDword-1);
+      } while(res);
+      res = false;
+      do {
+        res=::ReadFile(rPipeE, buffer, 128, &reDword, 0);
+        error += BText(buffer,0,reDword-1);
+      } while(res);
+
+      if(error.HasName()) {
+        ok = false;
+      } else {
+        ok = true;
+      }
+    }
+  }
+  return(ok);  
+}
+
+#endif
+
+//--------------------------------------------------------------------
+BBool BSys::PExecQuiet(const BText& command, 
+                       BText& output, BText& error)
+//--------------------------------------------------------------------
+{
+  SetLastError(0);
+  BText errNam = BSys::TempNam();
+  BText cmdRedirected = command + BText(" 2> ") + errNam;
+  bool ok = false;
+  FILE* pipe = popen(cmdRedirected, "r");
+  if(pipe) {
+    char buffer[128];
+    output = "";
+    while(!feof(pipe)) {
+      if(fgets(buffer, 128, pipe) != NULL)
+        output += buffer;
+    }
+    pclose(pipe);
+    if(CheckIsFile(errNam)) {
+      ReadFile(error,errNam);
+      remove(errNam.String());
+    }
+    if(error.HasName()) {
+      ok = false;
+    } else {
+      error = "";
+      ok = true;
+    }
+  } else {
+    output = "";
+    error = I2("Creating process \n",
+               "Creando el proceso \n") + command;
+    ok = false;
+  }
+  return(ok);
+};
 
 //--------------------------------------------------------------------
Index: tol/bbasic/tol_bsys.h
===================================================================
--- tol/bbasic/tol_bsys.h	(revision 5a1c98150d94c04703d7871426f7effdd7bb47cf)
+++ tol/bbasic/tol_bsys.h	(revision a94fd1cdb79c6eeb16c329460d160dc1ac8cb250)
@@ -31,4 +31,9 @@
 #include <tol/tol_bout.h>
 #include <tol/tol_blist.h>
+
+#ifdef WIN32
+#define popen _popen
+#define pclose _pclose
+#endif
 
 //--------------------------------------------------------------------
@@ -114,9 +119,12 @@
   
 #ifndef	  UNIX
-  static BBool	WinExecuteFile (const BText& fileName);
-  static BBool	WinSystem  (const BText& command,
-				                    BInt	showMode, 
-                            bool  wait=BFALSE);
+  static BBool	WinExecuteFile(const BText& fileName);
+  static BBool	WinSystem     (const BText& command,
+                               BInt  showMode, bool  wait=BFALSE);
+  static BBool	WinSystemQuiet(const BText& command,
+                               BText& output, BText& error);
 #endif
+  static BBool	PExecQuiet    (const BText& command, 
+                               BText& output, BText& error);
   static BBool ChildProcess(const BText& command);
   //! Prints a file in the default printer.
Index: tol/btol/set_type/setgra.cpp
===================================================================
--- tol/btol/set_type/setgra.cpp	(revision 5a1c98150d94c04703d7871426f7effdd7bb47cf)
+++ tol/btol/set_type/setgra.cpp	(revision a94fd1cdb79c6eeb16c329460d160dc1ac8cb250)
@@ -52,9 +52,4 @@
 
 #include "llkarma.h"
-
-#ifdef WIN32
-#define popen _popen
-#define pclose _pclose
-#endif
 
 //static const char* bayesVersionId =
@@ -2922,5 +2917,5 @@
 	  "(Set Args)",
 	  I2("Execute an external program. The output of the program is returned in the member output.",
-	     "Ejecuta un programa externo. la salida del programa se retorna en el miembro ouput del conjunto resultado."),
+	     "Ejecuta un programa externo. La salida del programa se retorna en el elemento output del conjunto resultante."),
 	  BOperClassify::System_);
 
@@ -2994,17 +2989,5 @@
     }
     if ( !badArg ) {
-      //Std( BText( "*** '" ) + cmd + "' ***" );
-      FILE* pipe = popen(cmd, "r");
-      if ( pipe ) {
-        char buffer[128];
-        output = "";
-        while( !feof( pipe ) ) {
-          if( fgets( buffer, 128, pipe ) != NULL )
-            output += buffer;
-        }
-        status = 1;
-        desc = "";
-        pclose( pipe );
-      }
+      status = BSys::PExecQuiet(cmd, output, desc);
     } else {
       status = 0;
@@ -3028,2 +3011,39 @@
   contens_.RobElement(result);  
 }
+
+//--------------------------------------------------------------------
+DeclareContensClass(BSet, BSetTemporary, BSetAnsSystemQuiet);
+DefExtOpr(1, BSetAnsSystemQuiet, "AnsSystemQuiet", 1, 1, "Text", 
+  "(Text command)",
+  I2("Calls the operative system to execute a command line "
+     "and returns the status, the standard output "
+     "and the standar error of the call in a set.",
+     "Llama al sistema operativo para ejecutar una línea de comandos "
+     "y devuelve un conjunto con el estado, "
+     "la salida estándar y los erorres de la llamada."),
+	  BOperClassify::System_);
+//--------------------------------------------------------------------
+void BSetAnsSystemQuiet::CalcContens()
+//--------------------------------------------------------------------
+{
+  if(CheckNonDeclarativeAction("AnsSystem")) { return; }
+  const BText& command = Text(Arg(1));
+  BBool status;
+  BText output, error;  
+#ifndef UNIX
+  // Se usa WinSystemQuiet ya que PExecQuiet 
+  // no puede evitar mostrar la ventana de la consola
+  status = BSys::WinSystemQuiet(command, output, error);
+#else
+  status = BSys::PExecQuiet(command, output, error);
+#endif
+  BList * result = NIL;
+  BSyntaxObject * so;
+  result = Cons(so = new BContensText("", error), result);
+  so->PutName("std_error");
+  result = Cons(so = new BContensText("", output), result);
+  so->PutName("std_output");
+  result = Cons(so = new BContensDat("", status), result);
+  so->PutName("status");
+  contens_.RobElement(result);  
+}
Index: tol/btol/text_type/txtgra.cpp
===================================================================
--- tol/btol/text_type/txtgra.cpp	(revision 5a1c98150d94c04703d7871426f7effdd7bb47cf)
+++ tol/btol/text_type/txtgra.cpp	(revision a94fd1cdb79c6eeb16c329460d160dc1ac8cb250)
@@ -2820,2 +2820,33 @@
   contens_ = CompareVersionString(&v1,&v2);
 }
+
+//--------------------------------------------------------------------
+  DeclareContensClass(BText, BTxtTemporary, BTextAnsSystem);
+  DefExtOpr(1, BTextAnsSystem, "AnsSystem", 1, 1, "Text", "(Text command)",
+  I2("Calls the operative system to execute a command line "
+     "and returns the standard output.",
+     "Llama al sistema operativo para ejecutar una línea de comandos "
+     "y devuelve la salida estándar de la llamada."),
+     BOperClassify::System_);
+  void BTextAnsSystem::CalcContens()
+//--------------------------------------------------------------------
+{
+  if(CheckNonDeclarativeAction("AnsSystem")) { return; }
+  const BText& command = Text(Arg(1));
+  BBool status;
+  BText output, error;
+#ifndef UNIX
+  // Se usa WinSystemQuiet ya que PExecQuiet 
+  // no puede evitar mostrar la ventana de la consola
+  status = BSys::WinSystemQuiet(command, output, error);
+#else
+  status = BSys::PExecQuiet(command, output, error);
+#endif
+  if(status) {
+    contens_ = output;
+  } else {
+    Error(I2("Operative system error \n",
+             "Error del sistema operativo \n")+error);
+    contens_ = BText("");
+  }
+}
