Nothing happened - CreateProcess() 
Author Message
 Nothing happened - CreateProcess()

When i use this procedure to call DOS command. Nothing happen!
Please can anybode help me? Where i made the mistake?

thanks in advance,
Tomas Volsicky

  BOOL bOk;
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
  sprintf (szCmd,"command.com copy aaaa.txt bbbb.txt");

   memset(&si,0,sizeof(STARTUPINFO));
  si.cb = sizeof(STARTUPINFO);
  si.wShowWindow = SW_SHOW;
  bOk = CreateProcess(NULL,szCmd,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);



Mon, 09 Jul 2001 03:00:00 GMT  
 Nothing happened - CreateProcess()

Quote:
> When i use this procedure to call DOS command. Nothing happen!
> Please can anybode help me? Where i made the mistake?

> thanks in advance,
> Tomas Volsicky

>   BOOL bOk;
>   STARTUPINFO si;
>   PROCESS_INFORMATION pi;
>   sprintf (szCmd,"command.com copy aaaa.txt bbbb.txt");

>    memset(&si,0,sizeof(STARTUPINFO));
>   si.cb = sizeof(STARTUPINFO);
>   si.wShowWindow = SW_SHOW;
>   bOk = CreateProcess(NULL,szCmd,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);

The first thing you need to do is add a /c parameter to your command line
as follows:

"command.com /c copy aaaa.txt bbbb.txt"

Once this is done and CreateProcess() still fails, then call
GetLastError() after CreateProces() to get extended error information.  
This should give you a clue about the cause of the failure.

--
*------------------------------------------------------------
| J. Keith Wedinger
| Technical Specialist - The Limited, Inc.

| http://www.serve.com/uccats
|



Mon, 09 Jul 2001 03:00:00 GMT  
 Nothing happened - CreateProcess()
Tomas!

Try to add the following code on failure, and Windows will tell you what's
wrong:

 LPVOID lpMsgBuf;

 // Format error message from system

 ::FormatMessage(
  FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
  NULL,
  GetLastError(),
  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
  (LPTSTR) &lpMsgBuf,
  0,
  NULL
 );

  AfxMessageBox((LPCSTR)lpMsgBuf);

 // Free the buffer.
 LocalFree( lpMsgBuf );



Mon, 09 Jul 2001 03:00:00 GMT  
 Nothing happened - CreateProcess()
this section of the article mentioned below would show correct usage
Behavior of CreateProcess When Executing a 16-bit .exe
INFO: Understanding CreateProcess and Command-line Arguments
Last reviewed: October 30, 1997
Article ID: Q175986

--
----------------------------------------
Rajesh Parikh
Microsoft Certified Solution Developer

----------------------------------------

Quote:

>When i use this procedure to call DOS command. Nothing happen!
>Please can anybode help me? Where i made the mistake?

>thanks in advance,
>Tomas Volsicky

>  BOOL bOk;
>  STARTUPINFO si;
>  PROCESS_INFORMATION pi;
>  sprintf (szCmd,"command.com copy aaaa.txt bbbb.txt");

>   memset(&si,0,sizeof(STARTUPINFO));
>  si.cb = sizeof(STARTUPINFO);
>  si.wShowWindow = SW_SHOW;
>  bOk = CreateProcess(NULL,szCmd,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);



Tue, 10 Jul 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem: Click openfile, nothing happens!

2. CreateProcess in CreateProcess

3. Data Relationships- Code says nothing has changed

4. Karim Mustapha Binalshibh: next Al Queda attack on Buy Nothing Day

5. Sadam Fahd Atef: next Al Queda attack on Buy Nothing Day

6. Pervez AL-Jabr: next Al Queda attack on Buy Nothing Day

7. Youssef Ghassan al Makhoul: Al Queda will destroy the infidels (next attack on Buy Nothing Day)

8. Nothing showing up...

9. Create DataSet Thru Code From Nothing?

10. fprintfing to nothing

11. initialize ComboBox to select nothing

12. AcceptButton does nothing?

 

 
Powered by phpBB® Forum Software