0 Replies Latest reply: Nov 15, 2015 6:09 PM by Loren Garavaglia RSS

Issues calling an external process during simulation

Loren Garavaglia

I'm trying to call an external command prompt process during a simulation.  In order to do that I call the process using the following code:

 

CreateProcess(NULL,   // No module name (use command line) TEXT("C:\\WINDOWS\\system32\\cmd.exe")
  (LPSTR)input,        // Command line  (LPSTR)input
  NULL,           // Process handle not inheritable
  NULL,           // Thread handle not inheritable
  FALSE,          // Set handle inheritance to FALSE
  0,              // No creation flags
  NULL,           // Use parent's environment block
  NULL,           // Use parent's starting directory 
  &si,            // Pointer to STARTUPINFO structure
  &pi )           // Pointer to PROCESS_INFORMATION structure
  ) 

 

Where my input string is my command line argument.  When I run my simulation I get an error code 183, which says "Cannot create a file when that file already exists.". 

 

So to resolve this I tried replacing the first argument "NULL" with the location of cmd.exe on my system.  When I run my simulation that way I do not get error code 183, however, my process only seems to stay active for 1 program loop and my Opnet process becomes unresponsive. 

 

I can run this instruction to start other programs such as notepad, but for some reason it doesn't want to work for a command prompt process. 

Is there something here that I'm doing wrong to create an external command prompt process?