Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys
can any one help me to know how to Copy a file to Drive "C:\" if we know this drive contain the Operating system "Win7".

i Use this code:
VB
Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Integer) As Integer
...
copyfile(strSource, strDest,True)


It work if run the program as administrator. Is there another way to do that??
Posted

No there is not, this is a restriction of the operating system which will not allow you to copy files to sensitive areas on disk.

You can however run your code as an administrator when needed see here : RunAs Class[^]
 
Share this answer
 
Comments
alcitect 10-Jan-13 5:59am    
thank you for answer, let me read your project
alcitect 10-Jan-13 6:00am    
thanks for your help but it not help me. thanks
You can get around this by setting your UAC to none,

Control Panel -> user Accounts -> UAC drag the slider to the bottom.
 
Share this answer
 
Comments
alcitect 10-Jan-13 6:03am    
yes that may be work. but i want to run this application on many computers.
thanks for help.
tiggerc 10-Jan-13 6:05am    
you could set the run as administrator in the application shortcut.
alcitect 10-Jan-13 6:17am    
can you show this for me pleas?
thanks
tiggerc 10-Jan-13 6:20am    
Create a shortcut to the application.
Right click on the shortcut, select properties
go to the compatability tab
select run this program as administrator.

if there is a button change settings for all users click that and check the box run as administrator.

click ok a couple of times, all should work.
tiggerc 10-Jan-13 7:10am    
did this work for you? if it did can you mark as solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900