Skip to content

Commit

Permalink
Really disallow us from running under elevated UAC
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed Feb 26, 2016
1 parent 449e5c5 commit a8e16fb
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/Setup/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,12 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,

bool isQuiet = (cmdLine.Find(L"-s") >= 0);
bool weAreUACElevated = CUpdateRunner::AreWeUACElevated() == S_OK;
bool explicitMachineInstall = (cmdLine.Find(L"--machine") >= 0);
bool attemptingToRerun = (cmdLine.Find(L"--rerunningWithoutUAC") >= 0);

if (explicitMachineInstall || weAreUACElevated) {
exitCode = MachineInstaller::PerformMachineInstallSetup();
if (exitCode != 0) goto out;
isQuiet = true;

// Make sure update.exe gets silent
if (explicitMachineInstall) {
wcscat(lpCmdLine, L" --silent");
printf("Machine-wide installation was successful! Users will see the app once they log out / log in again.\n");
}
if (weAreUACElevated && attemptingToRerun) {
CUpdateRunner::DisplayErrorMessage(CString(L"Please re-run this installer as a normal user instead of \"Run as Administrator\"."), NULL);
exitCode = E_FAIL;
goto out;
}

if (!CFxHelper::CanInstallDotNet4_5()) {
Expand Down Expand Up @@ -88,6 +82,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
wchar_t buf[4096];
HMODULE hMod = GetModuleHandle(NULL);
GetModuleFileNameW(hMod, buf, 4096);
wcscat(lpCmdLine, L" --rerunningWithoutUAC");

CUpdateRunner::ShellExecuteFromExplorer(buf, lpCmdLine);
exitCode = 0;
Expand Down

0 comments on commit a8e16fb

Please sign in to comment.