locked
How to get permission to access or read and write the system files

    Question

  • I want to replace a file using Visual Basic

    and i m using file.copy(path1,path2,boolean) method

     

    But it is a system file so i cannot replace the exixting file which is loacted in "C\Windows\System32".

    It require permission to read and write the files.

     

    So problem is this that how i can take permission to replace the file using Visual Basic Code .

    Friday, May 23, 2008 7:10 PM

Answers

  • Hi Ganesh,

    If you can type the commands in the command line to implement your requirement, you must can use the Process class to do the same operation. Visit this thread for your reference.

    Best regards,
    Riquel

    Tuesday, May 27, 2008 10:24 AM
    Moderator

All replies

  • well this is something you cannot do if you are trying to copy a system file as this is a Windows locked file. Remember, if this is a Windows application, it will run under the user account you are logged in as, so whatever permissions you have, your application will have and run under. If Windows is blocking you from copying or writing to a file, this is all to do with Windows.

     

    of course, if you have a restricted account, then you need to contact your Administrator to give you appropriate permissions to read/write to the file.

     

    what file is this specifically?

     

    Friday, May 23, 2008 7:18 PM
  • I want to replace C:\Windows\System32\authui.dll.

    But when i run my program then An exeption raise that i have not sufficient privillages to access this file and i cannot replace it.

     

    Using Commnad Prompt i get the privillage

    command is

     takeown /f C:\Windows\System32\authui.dll

    icacls /grant C:\Windows\System32\authui.dll Administrators:F

     

    But i also don't know how i execute this using Visual Basic.

    Friday, May 23, 2008 7:35 PM
  • you could execute this as a process then copy the file.

     

    looks like this is a System file only, and disallowed the administrator or other users to gain access to it for security reasons therefore I wouldn't advise copying the file or modifying it in any way.

     

    if you must, execute this in a process class:

     

    import the System.Diagnostics namespace then:

     

    Dim proc as new Process("takeown /f C:\windows\system32\authui.dll")

    Process.Start(proc)

    proc = new Process(icacls /grant C:\windows\system32\authui.dll Administrators:F")

    Process.Start(proc)

     

    Friday, May 23, 2008 7:44 PM
  • Still i does not find the solution because the code has some errors and does not execute.

    Is there any Funtion or method to get sufficient privilages to overwrite this file.

     

    I think that most of the software which interact with system files thay have all rights to access them to read and write.

     

    I am using Windows Vista UAC enabled in Administrator account.

    Saturday, May 24, 2008 5:00 PM
  • no there isnt a function that just gives you the right permission to access a file that is restricted access - that would be breaking security and defeating the purpose of file protection.

     

    when running your application, be sure you are running it under administrator account/mode in the UAC. So, right click your app > run as administrator.

     

    what happens now? I also dont think other applications can overwrite a Windows protected file, I doubt they would need to do this for tampering with an OS file

     

    Saturday, May 24, 2008 5:09 PM
  • Ya i in administrator mode in Windows Vista.

    there is also a example like this

     

    Uxtheme patcher

    these patcher get the rights to access the files and overwrite them, so i think this is possible but how i do'nt know.

     

    Can i chat with u please tell me ur E mail address ahmedilyas

    my email address is ganesh.india@live.com

    Saturday, May 24, 2008 5:17 PM
  • how i can  handle unauthorizedaccessexception in visual basic 2008

     

    when i manually get the all access write on this file then it can be overwrite but i want that all rights should take by Visual Basic Code script.

     

    Please help

     

    Saturday, May 24, 2008 5:40 PM
  • Hi Ganesh,

    If you can type the commands in the command line to implement your requirement, you must can use the Process class to do the same operation. Visit this thread for your reference.

    Best regards,
    Riquel

    Tuesday, May 27, 2008 10:24 AM
    Moderator