checkprocess()
{
char command[1024];
int i, total = 0;
char buffer[12], ch;
char *filename = lr_eval_string("C:\\tasklist_{pTime}.txt");
long file_stream;
sprintf(command, "tasklist /FI \"IMAGENAME eq MobileEngine.exe\"
/FI \"STATUS eq running\" /FO TABLE /NH > %s", filename);
system(command);
if ((file_stream = fopen(filename, "r")) == NULL ) {
lr_error_message("Cannot open %s", filename);
return -1;
}
for(i=0; (i<NUM_CHARS) && (feof(file_stream) == 0); i++) {
ch = fgetc(file_stream);
buffer[i] = ch;
}
buffer[i] = NULL;
lr_output_message("First %d characters of file %s are \"%s\"",
NUM_CHARS, filename, buffer);
if (fclose(file_stream)){
lr_error_message("Error closing file %s", filename);
};
if (strcmp(buffer, "\nMobileEngine") != 0) {
lr_error_message("The process is not running. Aborting Script...");
sprintf(command, "DEL %s", filename );
system(command);
return -1;
}
else{
lr_output_message("The process is running. Continue...");
sprintf(command, "DEL %s", filename );
system(command);
};
return 0;
}