File getting copied to SysWOW64 instead of System32 File getting copied to SysWOW64 instead of System32 windows windows

File getting copied to SysWOW64 instead of System32


You've run afoul of file system redirection.

Because %windir%\System32 is reserved exclusively for 64-bit applications, on 64-bit versions of Windows, 32-bit applications that attempt to access the %windir%\System32 directory are automatically and transparent redirected to the 32-bit %windir%\SysWOW64 directory.

First, make sure that your program actually does belong in the 64-bit system folder. Windows does this automatic redirection for a reason. 32-bit stuff does not go in the %windir%\System32 folder on 64-bit versions of Windows.

If you're certain that you want to be copying stuff into the 64-bit system directory, you have a couple of options. The easiest is probably to just compile your utility as a 64-bit application. Alternatively, you can tell the WOW64 redirector that you know what you're doing and not to perform the redirection by using %windir%\Sysnative instead of %windir%\System32.


I had the same problem. The solutions is to set the "Platform target" as x64 or AnyCPU instead of x86 in project properties in Visual Studio. In this case the path will be "C:\Windows\system32" and will not redirect to "C:\Windows\SysWOW64" You can check this by placing any file in the "C:\Windows\SysWOW64" folder and then use File.Exists command to check if file is found in that folder:

File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), sFileName));

Or

File.Exists(Path.Combine(Environment.SystemDirectory, sFileName));

enter image description here


As path environnement variable contains c:\windows on both windows x86/x64 versions,why not putting your tool into c:\windows : %windir%?

In my case this solve my problem.