有个bat文件xcopy /y %~dp0x64\43430r0nvram.txt %WINDIR%\System32\Drivers\
通过程序去调用bat文件,提示复制成功但是C盘下并没有文件。如果直接管理员运行bat文件就能复制成功C盘有文件,请问怎么回事?
1.UAC Executioin Level已经设置为 RequireAdministrator
2.直接在程序里CopyFile(_T("x64\43430r0nvram.txt"), _T("C:\Windows\System32\drivers\43430r0nvram.txt"), FALSE);也是不成功
3.C盘根目录可以,C:\windows\system32\drivers就不成功
if (Wow64EnableWow64FsRedirection(FALSE))
{
// Any function calls in this block of code should be as concise
// and as simple as possible to avoid unintended results.
ShellExecute(NULL, L"open", _T("CherryTrail\\AP6212\\Install_64_Auto.cmd"), NULL, NULL, SW_SHOWNORMAL);
// Immediately re-enable redirection. Note that any resources
// associated with OldValue are cleaned up by this call.
if(FALSE== Wow64EnableWow64FsRedirection(TRUE))
{
// Failure to re-enable redirection should be considered
// a criticial failure and execution aborted.
return;
}
}
https://msdn.microsoft.com/en-us/library/aa365744.aspx
发现你的程序是32位的,所以在64位系统下,所有对system32的操作都会被转向syswow64
文件自动跑到C:\Windows\SysWOW64\drivers
你的bat程序是32位的,做一个64位程序去复制文件
关键看你的系统是多少位数的
完美解决你的问题 http://blog.csdn.net/qq_37477609/article/details/79485552