locked
File not created in C:\Windows\System32 folder RRS feed

  • Question

  • Hi

    I got surprising behavior when I run following program on Windows server 2008.

     

    int _tmain(int argc, _TCHAR* argv[])

    {

                if(system("(cd) > C:\\Windows\\System32\\abc1.txt") == -1)

                {

                   printf("\n Error in system command");

                   return 0;

               }

        printf("Data is written to file\n");

       return 0;

    }

     

    I got message on console :"Data is written to file"

    But abc1.txt file is not created in C:\Windows\System32 folder.

    But when I run command (cd) > C:\Windows\System32\abc1.txt  from command promt then it works and file abc1.txt created.

     

    Also when I run same program on Windows Server 2003 then also it works

    This is really surprising to me!!!

    Can someone tell me what can be reason for this???

     

     

    Friday, July 9, 2010 9:26 AM

All replies

  • Maybe your file access is virtualized. Check if your app is targeting 64bit CPU and is running elevated.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Friday, July 9, 2010 7:40 PM
  • Got the solution!!!

    Thanks to Tim Roberts, DDK MVP

    Since I am running 32 bit binary on 64 bit OS machine File get redirected to C:\Windows\SysWOW64 folder

     

     

    Tuesday, July 13, 2010 6:50 AM