D
D
dronreviews2015-03-30 17:31:37
C++ / C#
dronreviews, 2015-03-30 17:31:37

How to run child C/C++ defrag process?

There is a console menu.
You need to start a child process with parameters. Here is an attempt to defragment drive C. What's wrong?
spawnl(P_WAIT,"defrag","C",NULL);
UPD:

#include "stdafx.h"
#include "windows.h"

void main()
{
  STARTUPINFO cif;
  ZeroMemory(&cif,sizeof(STARTUPINFO));
  PROCESS_INFORMATION pi;
  CreateProcess(L"c:\\windows\\system32\\defrag.exe",NULL,
    NULL,NULL,FALSE,NULL,NULL,NULL,&cif,&pi);
}

But how to pass the disk parameter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Martyanov, 2015-03-30
@vilgeforce

You better know what's wrong. It would be nice to specify the expected and actual behavior. I assume that specifying the absolute path to the file will solve the problem. You can also look at CreateProcess in order not to use any wrappers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question