1

I have created a batch file that copies some dll files into System32 folder. I ran this batch from my program written in C# code:

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();
}

Everything has worked fine. I got the popup message to confirm the change from Windows 7. The console also proved that the file had been copied:

C:\Program Files\XXX>copy commpro.dll C:\Windows\system32\
    1 file(s) copied.

But when I look in System32 folder I couldn't find my dlls there. It's so strange!

Does anybody occur this issue?

Edit: My question is different with this question: How to write files in C:\Windows\System32 with full permissions

Here I got the popup that allow me to grant permission to write to System32 folder. And the output of "copy" command didn't show "Access Denied" but "Copied". The problem is why it doesn't contain my dlls while it said "copied" ?

Community
  • 1
  • 1
Ninh Trung
  • 21
  • 4
  • @DavidArno: My account is under administrators group. And when I rightclicked and run the batch as Administrator it prompted me then went well. – Ninh Trung May 23 '15 at 08:56
  • 1
    Did you check to see if the file ends up in %windir%\SysWOW64. ? – sgmoore May 23 '15 at 09:07
  • @sgmoore: You are right. It was in SysWow64. Is it because OS move all the file that copied to System32 to SysWOW64? If so, does my app still run normally? – Ninh Trung May 23 '15 at 09:18

1 Answers1

2

If your app is a 32-bit application, then the file will end up in the %windir%\SysWOW64 folder. See this page on Msdn for more details.

Your 32-bit application should be able to see this file.

I should point out that copying dlls to your system folder is usually a bad idea and should be avoided if at all possible.

sgmoore
  • 15,694
  • 5
  • 43
  • 67