When you execute that program from POIDE it use that limited search PATH as i showed with that example with SET-command.
Outside POIDE you program should find that notepad.exe
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
system("notepad somefile.c");
//system("set");
printf("%s\n", getenv("PATH"));
return 0;
}
Compile that example and check that PATH enviroment variable