Reputation: 730
I am trying to replace a file in the C:\Windows\System32
directory but it won't work.
(For them who mean my program is a virus: No, it isn't!)
Some information about the environment:
I've already added the application manifest and changed the requestedExecutionLevel
.
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
I have also tried to use a BATCH to replace the file but I get the same error.
Is there any way to replace the file?
For example explicitly ask for FileIOPermissions.Write
or .AllAccess
.
Upvotes: 0
Views: 1698
Reputation: 69979
If your system is 64 bit, but your application is 32 bit, this may help. From Dalong Zhang's answer to the Can't copy files under C:\Windows\System32\inetsrv\config by C# question on the Microsoft forum:
Because so many applications have hard-coded the System32 directory name into paths, MS put the 64-bit systems files there instead of in a 'System64' directory. The 32-bit versions now go into a 'SysWOW64' directory. but in order to prevent breaking 32-bit programs, the system performs a redirection by default for 32-bit processes trying to access the 'System32' directory. In most cases, whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64.
A simple way to get around this redirection is to use %windir%\Sysnative instead of %windir%\System32. Win64 will 'redirect' that directory to the actual System32 directory.
You can use the
Wow64DisableWow64FsRedirection()
API to completely disable this redirection. See http://msdn.microsoft.com/en-us/library/aa384187.aspx for details
Upvotes: 1