I have 2 loaders (loader1 and loader2). I also have a Pinger which depends on the call i give will execute either loader1 or loader2. I have problem that the pointer strloaderPath. The problem like you see below if i call loader1 this program will execute loader by getting the environment variable. So the first time I call loader1 strloaderPath will get the env variable which will be c:\program Files\ then it will use strcat to add loader1.exe to execute it. Now if i want to execute loader2 when strloaderPath get the environment variable it will get it wrong it will get c:\program files\loader1.exe which is wrong because it should only get c:\program files then if i do strcat it should show c:\program files\loader2.exe and not c:\program files\loader1.exe\loader2.exe

switch (Status)
{
case RFX_SUCCESS:
char strLog[20];
char strLoader[256];
char *pFind;
int lLength;
char *strLoaderPath;

strLoaderPath = getenv("BSI_CF_DIR");
if (Request.APIType == RFX_USE_RF_API) {
pFind = strstr(strLoaderPath, "loader1.exe");
if (pFind == NULL){
strcat(strLoaderPath, "\\loader1.exe ");}
}
else {
pFind = strstr(strLoaderPath, "loader2.exe");
if (pFind == NULL){
strcat(strLoaderPath, "\\loader2.exe ");}
}
itoa(Request.RequestNumber,strLog,10);
strcat(strLoader, strLog);
strcat(strLoader, " ");
strcat(strLoader, Request.DataSetID);
STARTUPINFO si;
::ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
PROCESS_INFORMATION pi;
lLength = CreateProcess(NULL,strLoader,NULL,NULL,FALSE,CREAT E_NEW_CONSOLE,NULL,NULL,&si, &pi);
if (! lLength){
error("CreateProcess failed");}
break;
}