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
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.
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
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)
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....!
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.
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..?
Re: Not able to Copy files in System 32 folder Vista...!
Quote:
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:
Quote:
Copies, moves, renames, or deletes a file system object. This function has been replaced in Windows Vista by
IFileOperation.