CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2008
    Posts
    13

    Question Not able to Copy files in System 32 folder Vista...!

    Friends ,


    I have used VC++ 2003, 2005 n 2008 on Vista 64 bit Home premium edition.


    My program consists of a simple application which copied the file from one location to another (System32 folder in C:\Windows). But i keep on getting access denied error...


    Hopefully someone will help me resolve this freak issue...

    Thanks,
    Bradd

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Not able to Copy files in System 32 folder Vista...!

    I'm not a Vista user, but my first guess would be that you don't have to rights to copy the files.

  3. #3
    Join Date
    Dec 2008
    Posts
    13

    Re: Not able to Copy files in System 32 folder Vista...!

    Had it been the problem of rights then I wouldn't have been able to copy the files in explorer....

    Able to copy files using batch files locally and also in explorer...

    But when the same batch files is run using vc++ "Access denied error comes up"

    Am I missing something....??

    Pls help,

    Thanks,
    Bradd

  4. #4
    Join Date
    Oct 2008
    Posts
    116

    Re: Not able to Copy files in System 32 folder Vista...!

    Maybe your program have to run in admin mode.
    ( right-click and choose Run As Administrator)
    My English is very bad. So tell me if Something I talked make u confuse.
    My Ebook Store: www.coding.vn/book.php

  5. #5
    Join Date
    Dec 2008
    Posts
    13

    Question Re: Not able to Copy files in System 32 folder Vista...!

    I am not running an exe but instead just debugging the code...

    Following is the code that i am using :-

    ***********************************

    void main()
    {

    LPCWSTR source;
    LPCWSTR destination;

    source = L"D:\\Test\\abc.dll";

    destination = L"C:\\Windows\\system32\\abc.dll";

    if(!CopyFile(source, destination, FALSE))
    ErrorExit(TEXT("CopyFile"));
    MessageBox(NULL, L"Not Copied", L"NoCopy", MB_OK);

    }

    ***********************************

    Copyfile throws up the error....!

  6. #6
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Not able to Copy files in System 32 folder Vista...!

    If you're debugging, you ARE running the EXE, just running it one line at a time.

  7. #7
    Join Date
    Dec 2008
    Posts
    13

    Re: Not able to Copy files in System 32 folder Vista...!

    That's right but i just wanted to clarify on the

    "right click--> run as admin "

    part...


    Anyhow , any ideas what the problem might be..?

  8. #8
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Not able to Copy files in System 32 folder Vista...!

    Had it been the problem of rights then I wouldn't have been able to copy the files in explorer....
    CopyFile is a function that exists from the beginning. Maybe it doesn't now how to work with the Vista security levels. Try SHFileOperation. The explorer uses the same function (AFAIK).

    edit : oops... after reading the posted link I noticed this:
    Copies, moves, renames, or deletes a file system object. This function has been replaced in Windows Vista by IFileOperation.
    Last edited by Skizmo; September 21st, 2009 at 08:07 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured