Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-Machine installs #337

Merged
merged 14 commits into from
May 11, 2015
Prev Previous commit
Next Next commit
Fix semantics around --machine and silent install
anaisbetts committed May 11, 2015
commit bcac028a7734659a8773bcfad03ade7d3ab62309
16 changes: 12 additions & 4 deletions src/Setup/winmain.cpp
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
exitCode = 0;
goto out;
}

// Make sure update.exe gets silent
wcscat(lpCmdLine, L" --silent");
}

HRESULT hr = ::CoInitialize(NULL);
@@ -32,11 +35,18 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
hr = _Module.Init(NULL, hInstance);

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

if (cmdLine.Find(L"--machine") >= 0 || CUpdateRunner::AreWeUACElevated() == S_OK) {
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");
}
}

if (!CFxHelper::CanInstallDotNet4_5()) {
@@ -60,11 +70,9 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
}
}

hr = CUpdateRunner::AreWeUACElevated();

// If we're UAC-elevated, we shouldn't be because it will give us permissions
// problems later. Just silently rerun ourselves.
if (hr == S_OK) {
if (weAreUACElevated) {
wchar_t buf[4096];
HMODULE hMod = GetModuleHandle(NULL);
GetModuleFileNameW(hMod, buf, 4096);