hello am trying to start another exe from my c program , am usign createprocess() but am getting error that , the commond is not recognized as internal or external

  STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(startupInfo);

PROCESS_INFORMATION processInformation;
  CreateProcess(
 bpath,    // bpath is char and  have    C:\myf\myapp.exe
  NULL,
  NULL,
  NULL,
  FALSE,
  NORMAL_PRIORITY_CLASS,
  NULL,
  NULL,
  &startupInfo,
  &processInformation
);
nova37
Deleted Member

bpath is char and have C:\myf\myapp.exe

If you mean bpath is a char-pointer try C:/myf/myapp.exe instead. The \ is an escape symbol but / is recognised as the directory delimiter under windows and *nix.

its run time error , i can't use / and / because i get windows dir using

char wdir[255];
GetWindowsDirectory(wdir,255);

so in wdir i get something like c:\windows\system32\
so start cmd i convert wdir to srting and then add \cmd.exe to that and convert again that string to char .
so in copy , move cases etc bpath works fine but in createprocess() it not works ????

Edited 3 Years Ago by nova37: spell

On my computer GetWindowsDirectory() returns "c:\windows", not "c:\windows\system32\"; Check the output of GetWindowsDirectory() to see if it is returning what you think it is returning

#include "stdafx.h"
#include <Windows.h>

#include <iostream>
using std::cout;

int main(int argc, char* argv[])
{
    char wdir[255] = {0};
    GetWindowsDirectory(wdir,sizeof(wdir));
    cout << wdir << '\n';
    return 0;
}
This article has been dead for over six months. Start a new discussion instead.