I'm working on a DLL file that extracts a resource file (.exe) from it to TEMP folder and executes it. The problem is it fails to execute the file unless the application that is using the DLL file is elevated (has administrator privileges). When I open TEMP folder from file explorer and double-click the extracted file, I get a UAC prompt. And when I click on "change when this notification appears" it is set to default (when a program tries to make changes to your computer). And I really don't understand why I get this notification because it's just a random file that runs without privileges on my PC unless it's extracted from the DLL. I use Windows 8 and Visual Studio 2013. Here's a part of the code of the DLL file:
HANDLE hFile = CreateFile(exePath, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) continue;
WriteFile(hFile, pExeResource, SizeofResource(hinstDLL, hrsrc), NULL, NULL);
CloseHandle(hFile);
if (!CreateProcess(exePath, NULL, NULL, NULL, FALSE, REALTIME_PRIORITY_CLASS, NULL, tmpPath, &info, &pi))
cout << "FAIL !\n";
else cout << "SUCCESS !\n";