mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-15 16:59:18 +01:00
Updater: Check for write permissions in directory of Updater.exe.
This commit is contained in:
parent
8f5a58f8be
commit
f0fb8c22b0
@ -31,7 +31,15 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||||||
// Test for write permissions
|
// Test for write permissions
|
||||||
bool need_admin = false;
|
bool need_admin = false;
|
||||||
|
|
||||||
FILE* test_fh = fopen("Updater.log", "w");
|
auto path = GetModuleName(hInstance);
|
||||||
|
if (!path)
|
||||||
|
{
|
||||||
|
UI::Error("Failed to get updater filename.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* test_fh =
|
||||||
|
_wfopen((std::filesystem::path(*path).parent_path() / "Updater.log").c_str(), L"w");
|
||||||
|
|
||||||
if (test_fh == nullptr)
|
if (test_fh == nullptr)
|
||||||
need_admin = true;
|
need_admin = true;
|
||||||
@ -47,13 +55,6 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto path = GetModuleName(hInstance);
|
|
||||||
if (!path)
|
|
||||||
{
|
|
||||||
MessageBox(nullptr, L"Failed to get updater filename.", L"Error", MB_ICONERROR);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Relaunch the updater as administrator
|
// Relaunch the updater as administrator
|
||||||
ShellExecuteW(nullptr, L"runas", path->c_str(), pCmdLine, NULL, SW_SHOW);
|
ShellExecuteW(nullptr, L"runas", path->c_str(), pCmdLine, NULL, SW_SHOW);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user