I want to list all the files that run under Task Scheduler by accessing all the files in the "C:\windows\system32\Tasks" Directory.
The program should recursively keep opening subfolders in the directory and list all the files. I currently use Windows OS.
I tried using the COM library but it doesn't display the tasks in the subfolders. I have 60 tasks but it displays only 12. So, I'm trying to iterate through the Tasks folder instead.
#include <stdio.h>
#include <dirent.h>
int main(void)
{
DIR *dir;
struct dirent *de;
if ((dir = opendir("C:\\Windows\\System32\\Tasks")) != NULL);
{
printf("The startup Programs are:\n");
while ((de = readdir(dir)) != NULL)
{
printf("%s\n", de->d_name);
}
closedir(dir);
}
getchar();
}
I expected the output to display all the files inside the current folder and the subfolders. However, the output only displays the name of the first folder and exits.