Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with CreateProcess

Status
Not open for further replies.

AliFessi

Programmer
Jul 3, 2001
12
DE
Hi there,

I have problems with CreateProcess. I cannot realize even a simple DOS-command.

Can you tell me what is wrong in this source code?

/**************************/
STARTUPINFO si;
PROCESS_INFORMATION pi;
si.cb = sizeof(si);

char cmd[] = "rename D:\\Documents\\myFile.txt output.txt";

if(! CreateProcess( NULL ,cmd, NULL , NULL , FALSE , 0 , NULL , NULL , &si , &pi ))
m_sOutput = "Success";
else
m_sOutput = "Error";

UpdateData(false);
/**************************/

As you can see I am using MFC here. In this example the function CreateProcess returns no error but it has no effect!

Thanks in advance!
 
Hello,

The problem is this. What your are doing is not a process. A process is, in a sense, an executable. This "rename D:\\Documents\\myFile.txt output.txt" is a command.

There is a function to use that acts as if you were typing on the command line in DOS. It's not comming to me right now but I'll let you know when it does.

Brother C


 
The first parameter shoudl be the path to executable, or just its name. The second is what you put in command line for it. So the second function argument will be the parameters for the first argument. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top