Fixed that "Edit skin" causes a needless UAC elevation prompt in some cases.

This commit is contained in:
Birunthan Mohanathas
2011-09-24 13:43:14 +00:00
parent 834bcd7bcd
commit e3bde6879b
4 changed files with 59 additions and 53 deletions

View File

@ -3621,20 +3621,23 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (wParam == ID_CONTEXT_SKINMENU_EDITSKIN)
{
std::wstring command = m_Rainmeter->GetConfigEditor() + L" \"";
command += m_SkinPath;
command += m_SkinName;
std::wstring command = m_SkinPath + m_SkinName;
command += L"\\";
command += m_SkinIniFile;
HANDLE file = CreateFile(command.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
command.insert(0, L" \"");
command.insert(0, m_Rainmeter->GetConfigEditor());
command += L"\"";
// If the skins are in the program folder start the editor as admin
if (m_Rainmeter->GetPath() + L"Skins\\" == m_Rainmeter->GetSkinPath())
if (file == INVALID_HANDLE_VALUE)
{
LSExecuteAsAdmin(NULL, command.c_str(), SW_SHOWNORMAL);
// File is in protected location, so execute as admin
ExecuteCommand(NULL, command.c_str(), SW_SHOWNORMAL, L"runas");
}
else
{
CloseHandle(file);
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
}
}