If I run a process with ShellExecute
(or in .net with System.Diagnostics.Process.Start()
) the filename process to start doesn\'t need to be a full
Much shorter and direct, which is what the poster wanted.
FILE *fp
char loc_of_notepad[80] = "Not Found";
// Create a pipe to run the build-in where command
// It will return the location of notepad
fp = popen("cmd /C where notepad", "r");
// Read a line from the pipe, if notepad is found
// this will be the location (followed by a '\n')
fgets(loc_of_notepad, 80, fp);
fclose(fp);
printf("Notepad Location: %s", loc_of_notepad);