help copying a file into system32 folder


using namespace std;

int main(int argc,char *argv[])
char name;
ifstream ifs("c:\\alien.jpg", ios::binary);
ofstream ofs("%systemroot%\\System32\\oobe\\info\\backgrounds\\hello.jpg", ios::binary);
ofs << ifs.rdbuf();
return 0;

i am trying to copy the image alien.jpg to c:\windows\system32\oobe\info\backgrounds folder. when i run this code i am getting success message but the file is not being copied to backgrounds folder.

Someone please help.
%systemroot% is a batch variable (environmental variable), I'm not sure that C++ will know what that means.*

(Maybe) try:

*Okay so the C++ compiler does NOT understand the syntax from the environment, but it's in a string, so perhaps the ostream constructor could do something with it. I doubt it will, but maybe...
Last edited on
closed account (4i67ko23)
Doesn't your program need admin permission to copy files to the windows folder?
i also tried running the program as administrator but its not working
closed account (DSLq5Di1)
Why are you copying a file with <fstream>??
Topic archived. No new replies allowed.