文件中获取复制到Syswow64资料,而不是System32下 [英] File getting copied to SysWOW64 instead of System32

查看:1527
本文介绍了文件中获取复制到Syswow64资料,而不是System32下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个psTool程序复制到System32文件夹中时,我的应用程序运行。
我在64位Windows 7何时何地,我试图通过 File.Copy 复制EXE到SYSTEM32文件夹位的EXE始终被复制到SysWow64文件代替。

I have to copy a psTool utility to System32 folder when my application runs.
I am on 64 bit Windows 7 and whenever, I try to copy the exe to system32 bit folder through File.Copy, the exe always gets copied to SysWow64 instead.

当我把一个断点destFile,路径显示为 C:\ Windows \ System32下,但该文件不进去(去SYSWOW64)。我已经试过了特殊文件夹 SystemX86 ,但文件再次进入SYSWOW64。

When I put a breakpoint on destFile, the path is shown as C:\Windows\System32 but the file does not go in there (goes to sysWow64). I have tried the Special Folder SystemX86, but the file again goes to sysWOW64.

string sourceFile = "C:\bin\Debug\somexe.exe"
string destFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), utilityName);
File.Copy(sourceFile, destFile, true);

任何建议什么,我在这里失踪?

Any suggestions what I am missing here?

修改

由于在回答指出下面,有文件系统重定向发生。我正在开发与Visual Studio的在64位操作系统的控制台应用程序的默认设置的应用程序。我不知道该怎么设置/交换机都在编译时必须保持,从而使应用程序在32位和64位操作系统是双向。
基本上,它应该只设置将文件复制到 System32下只不管是什么位操作系统是。
后来在节目中,我已经访问psTools工具,通过命令行是不可用,如果我把它放在SysWOW64中。如果我做出改变,使用SysWOW64中的32位CMD.EXE,这将又是一些64位平台特定的,这是我不想选择。

As pointed out below in the answer, there's file system redirection taking place. I am developing the app with the default settings of Visual Studio for a console application on a 64 bit OS. I am not sure what settings/switches have to be kept while compiling, so that the application works both on 32 bit and 64 bit OS.
Basically, it should just set copy the file to System32 only regardless of what bit OS it is.
Later in the program, I have to access the psTools utility through command line which is not available if I place it in SysWOW64. If I make change, to use SysWOW64's 32 bit cmd.exe, this would again be something 64 bit platform specific, which I do not want to opt.

它可以有没有问题,同时运行32位和64位应用程序的任何解决方案?我是否需要修改code(如何?)还是必须修改这个控制​​台应用程序项目的某些属性(属性)?

Any solution which can have the app running both on 32-bit and 64 bit without an problems? Do I have to modify the code (how?) or do I have to modify some properties of this console application project (which properties)?

推荐答案

您已经触犯的文件运行系统重定向

由于%WINDIR%\ System32下专供64位应用程序,在尝试访问64位版本的Windows,32位应用程序的%WINDIR%\ System32下目录中自动和透明的重定向到32位%WINDIR%\ Syswow64资料目录。

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.

首先,确保你的程序的实际上是在64位系统文件夹,确实属于的。 Windows不会这个自动重定向是有原因的。 32位的东西不进去的%WINDIR%\ System32下文件夹在64位版本的Windows

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.

如果您确定要被复制的东西到64位系统目录下,你有两个选择。最简单的可能是只编译工具为64位应用程序。或者,你可以告诉WOW64重定向你知道自己在做什么,而不是使用%WINDIR执行重定向%\ Sysnative 而不是 %WINDIR%\ System32下

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.

这篇关于文件中获取复制到Syswow64资料,而不是System32下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆