Name

wsystem - execute a shell command

Library

libc.lib

Synopsis

  #include <wchar.h>
  int wsystem (const wchar_t *string);

Return values

The wsystem function returns the exit status of the child process as returned by process’ exit reason or -1 if an error occurred when spawning a new process.

Detailed description

The wsystem function spawns another process with the argument string. The calling process waits for the child process to finish executing.

If string is a NULL pointer, wsystem will return non-zero to indicate that wsystem is suporrted and zero if it is not supported.


Examples

#include <stdlib.h>
#include <stdio.h> //printf
#include <wchar.h>
 
int main( void )
{
   int retVal = -1;
  
   printf( "Calling wsystem()...\n" );
  
   /* helloworld.exe is an executable that just prints
    * "Hello world!" and it should be created before
    * executing this example code.
    */
   retVal = wsystem(L"c:\\sys\\bin\\helloworld.exe");
   
   /* Print the return value of wsystem() */
   printf( "wsystem() returned: %d", retVal );
   
   return 0;
}

         

Output

Calling wsystem()...
wsystem() returned: -1

         

See also

wpopen

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top