Results 1 to 5 of 5

Thread: [RESOLVED] Modifying System32 Files / Backup

  1. #1

    Thread Starter
    Lively Member kshadow22's Avatar
    Join Date
    Dec 2014
    Location
    Kentucky
    Posts
    95

    Resolved [RESOLVED] Modifying System32 Files / Backup

    I have been working on a program that copies, renames, and modifies system32 files. I ran into a major problem where I was receiving an error "access is denied" even with escalated privileges. I did my research on the topic and couldn't find much information to help me. I came across the article: "The 'Program Files (x86)' and 'SysWOW64' folders explained" where the systems folders are further explained. I found that I was running my program as 32bit / anyCPU. This caused my application to search in a directory other than the system32 for the files that I had specified such as cmd.exe, sethc.exe, notepad.exe, and etc. This was why I was receiving "access is denied".

    With receiving this message, it was nice to know that it was no longer a administrator problem, but a file location / access issue. I switched my program configuration to 64bit and now the program has the privileges and correct configuration to modify these files.

    If you are experiencing issues with this, you can configure your program to 64bit by:
    1. Go to Build menu
    2. Select Configuration Manager
    3. In the Active solution platform list, select the 64-bit platform for the solution to target.
    4. If you do not see the option, select New
    5. In the New Solution Platform dialog box, select the 64-bit platform for the solution to target.
    6. Now the build of the project will be optimized for 64-bit platforms.

    For my project, I was replacing the sethc.exe with the cmd.exe, and creating a backup of the sethc.exe. My reason behind this madness was to create a shortcut to the cmd.exe by the activation of sticky keys since I never use sticky keys. Below you can see the code I used.
    vb.net Code:
    1. Try
    2.                 Dim SETHC_Path As String = "C:\Windows\System32\sethc.exe"
    3.                 Dim SETHC_PathNew As String = "sethc_original.exe"
    4.                 Dim CMD_Path As String = "C:\Windows\System32\cmd.exe"
    5.                 If System.IO.File.Exists(SETHC_Path) And System.IO.File.Exists(CMD_Path) Then
    6.                     My.Computer.FileSystem.RenameFile(SETHC_Path, SETHC_PathNew)
    7.                     My.Computer.FileSystem.CopyFile(CMD_Path, SETHC_Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.UICancelOption.DoNothing)
    8.  
    9.                 Else
    10.                     MessageBox.Show("Unable to complete this process due to either the sethc.exe or cmd.exe missing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    11.                 End If
    12.             Catch ex As Exception
    13.                 MessageBox.Show("Error Renaming / Copying sethc or cmd.       " & ex.Message)
    14.             End Try

    If you happen to be building a program that works with both configurations (64/32), you can read this article: "File System Redirector" on the Microsoft's website where they discuss how you can use "%windir%" for the file location.

    If you want the application to discern between 32bit and 64bit, you can use the following information from "How to check if OS is 32 Bit OS or 64 Bit":

    "
    vb.net Code:
    1. Environment.Is64BitOperatingSystem
    (which) Determines whether the current operating system is a 64-bit operating system.

    The assumption being that a false signifies a 32bit environment.

    If you want to find out if the process is 64bit (as you can run a 32bit process on a 64bit OS), use
    vb.net Code:
    1. Environment.Is64BitProcess
    :
    (which) Determines whether the current process is a 64-bit process.
    "
    Last edited by kshadow22; Jul 17th, 2019 at 08:31 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: [RESOLVED] Modifying System32 Files / Backup

    As far as I can tell, you are sharing information rather than asking a question. In that case, this thread ought to be in the VB.NET CodeBank forum, rather than the VB.NET forum. If so, please use the Report Post icon under your post to send a message to the mods, asking them to move it there.

  3. #3

    Thread Starter
    Lively Member kshadow22's Avatar
    Join Date
    Dec 2014
    Location
    Kentucky
    Posts
    95

    Re: [RESOLVED] Modifying System32 Files / Backup

    Quote Originally Posted by jmcilhinney View Post
    As far as I can tell, you are sharing information rather than asking a question. In that case, this thread ought to be in the VB.NET CodeBank forum, rather than the VB.NET forum. If so, please use the Report Post icon under your post to send a message to the mods, asking them to move it there.
    I reported that. I tried putting it into the code bank when I created it, but it would not let me.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: [RESOLVED] Modifying System32 Files / Backup

    Maybe you need to have at least a 100 post count to post to the CodeBank. Not sure. The mods will sort it out.

  5. #5
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,900

    Re: [RESOLVED] Modifying System32 Files / Backup

    Moved to code bank and thanks for making a contribution
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Tags for this Thread

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