-
Jul 17th, 2019, 08:07 PM
#1
Thread Starter
Lively Member
[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:
Try Dim SETHC_Path As String = "C:\Windows\System32\sethc.exe" Dim SETHC_PathNew As String = "sethc_original.exe" Dim CMD_Path As String = "C:\Windows\System32\cmd.exe" If System.IO.File.Exists(SETHC_Path) And System.IO.File.Exists(CMD_Path) Then My.Computer.FileSystem.RenameFile(SETHC_Path, SETHC_PathNew) My.Computer.FileSystem.CopyFile(CMD_Path, SETHC_Path, FileIO.UIOption.OnlyErrorDialogs, FileIO.UICancelOption.DoNothing) Else MessageBox.Show("Unable to complete this process due to either the sethc.exe or cmd.exe missing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If Catch ex As Exception MessageBox.Show("Error Renaming / Copying sethc or cmd. " & ex.Message) 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:
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:
Environment.Is64BitProcess
:
(which) Determines whether the current process is a 64-bit process.
"
Last edited by kshadow22; Jul 17th, 2019 at 08:31 PM.
-
Jul 17th, 2019, 09:00 PM
#2
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.
-
Jul 17th, 2019, 09:43 PM
#3
Thread Starter
Lively Member
Re: [RESOLVED] Modifying System32 Files / Backup
Originally Posted by jmcilhinney
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.
-
Jul 17th, 2019, 09:49 PM
#4
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.
-
Jul 18th, 2019, 07:31 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|