Список файлов на диске PowerShell + с++



#include "stdafx.h"
#include <iostream>
#include <aclapi.h>


using namespace std;



int main()
{
 STARTUPINFO cif;
 ZeroMemory(&cif, sizeof(STARTUPINFO));
 PROCESS_INFORMATION pi;
 if (CreateProcess(_T("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"), _T("%s  get-childitem  -recurse -Name -path C:\\ > c:\\users\\trev\\extfile.log"), // > c:\\users\\trev\\extfile.log
  NULL, NULL, FALSE, NULL, NULL, NULL, &cif, &pi) == TRUE)
 {
  WaitForSingleObject(pi.hProcess, INFINITE);

  cout << "process" << endl;
  cout << "handle " << pi.hProcess << endl;
  TerminateProcess(pi.hProcess, NO_ERROR); // убрать процесс
 }else {
  cout << "error" << endl; 
  printf("CreateProcess failed (%d).\n", GetLastError());
  system("Pause");
 }
    return 0;
}


Поиск по этому блогу