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" ?
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.