【发布时间】:2015-05-23 08:47:50
【问题描述】:
我创建了一个批处理文件,它将一些 dll 文件复制到 System32 文件夹中。 我从我用 C# 代码编写的程序中运行了这批:
string path = @"ABC\install.bat";
ProcessStartInfo procStartInfo = new ProcessStartInfo()
{
UseShellExecute = true,
CreateNoWindow = false,
FileName = "\"" + path + "\"",
//Arguments = "\"" + path + "\""
Verb = "runas"
};
using (Process proc = new Process())
{
proc.StartInfo = procStartInfo;
proc.Start();
}
一切正常。我收到了确认从 Windows 7 更改的弹出消息。控制台也证明文件已被复制:
C:\Program Files\XXX>copy commpro.dll C:\Windows\system32\
1 file(s) copied.
但是当我查看 System32 文件夹时,我在那里找不到我的 dll。 好奇怪!
有人遇到这个问题吗?
编辑:我的问题与这个问题不同:How to write files in C:\Windows\System32 with full permissions
在这里,我得到了允许我授予写入 System32 文件夹的权限的弹出窗口。并且“复制”命令的输出没有显示“拒绝访问”而是“复制”。 问题是为什么它说“已复制”时不包含我的 dll?
【问题讨论】:
-
@DavidArno:我的帐户在管理员组下。当我右键单击并以管理员身份运行批处理时,它提示我然后运行良好。
-
您是否检查了文件是否以 %windir%\SysWOW64 结尾。 ?
-
@sgmoore:你是对的。它在 SysWow64 中。是因为操作系统将复制到 System32 的所有文件移动到 SysWOW64 吗?如果是这样,我的应用还能正常运行吗?
标签: c# batch-file dll windows-7-x64 system32