Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #include <windows.h>
  3. #include "errors.hxx"
  4. STATUS_T
  5. Execute( char* szCmd, char* szCmdFile )
  6. {
  7. PROCESS_INFORMATION prc;
  8. STARTUPINFO info;
  9. BOOL fCreated;
  10. char cmdLine[512];
  11. STATUS_T status = STATUS_OK;
  12. ZeroMemory( &info, sizeof( info ) );
  13. info.cb = sizeof( info );
  14. info.hStdError = GetStdHandle( STD_ERROR_HANDLE );
  15. info.hStdInput = GetStdHandle( STD_INPUT_HANDLE );
  16. info.hStdOutput = GetStdHandle( STD_OUTPUT_HANDLE );
  17. strcpy( cmdLine, szCmd );
  18. strcat( cmdLine, " \"" ); // quote the command file in case it has
  19. strcat( cmdLine, szCmdFile ); // spaces in the path
  20. strcat( cmdLine, "\" " );
  21. fCreated = CreateProcess( NULL, cmdLine, 0, 0, TRUE, 0, 0, 0, &info, &prc );
  22. if ( fCreated )
  23. {
  24. WaitForSingleObject( prc.hProcess, INFINITE );
  25. GetExitCodeProcess( prc.hProcess, ( LPDWORD ) &status );
  26. CloseHandle( prc.hThread );
  27. CloseHandle( prc.hProcess );
  28. }
  29. else
  30. {
  31. status = SPAWN_ERROR;
  32. }
  33. return status;
  34. }