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

Prevent node from running and installing on Windows Vista or earlier #5167

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/node_main.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#include "node.h"

#ifdef _WIN32
#include <VersionHelpers.h>

int wmain(int argc, wchar_t *wargv[]) {
if (!IsWindows7OrGreater()) {
fprintf(stderr, "This application is only supported on Windows 7, "
"Windows Server 2008 R2, or higher.");
exit(1);
}

// Convert argv to to UTF8
char** argv = new char*[argc];
for (int i = 0; i < argc; i++) {
Expand Down
4 changes: 4 additions & 0 deletions tools/msvs/msi/product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
Compressed="yes"
InstallScope="perMachine"/>

<Condition Message="This application is only supported on Windows 7, Windows Server 2008 R2, or higher.">
<![CDATA[Installed OR (VersionNT >= 601)]]>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as a negative condition? if this is false then the message is displayed?

Also, does Installed here mean that if you already have Node installed and try to install v6 then it's not going to give you this error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is that this is placed in a condition table in the MSI. The installer will only launch if the conditions are all true.

Installed is true when uninstalling and false when installing. @orangemocha we must make sure this works as intended when upgrading, in both Vista and 7.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as a negative condition? if this is false then the message is displayed?

Correct. The condition must be true for the installer to continue, otherwise the message is displayed.

I have tested a variety of upgrade scenarios and the current condition works fine. As noted, Installed is true when uninstalling and false when installing, and it refers to the current MSI, not any other installed versions of the product. So the Installed property in the condition is to make sure that this version of the MSI with the condition can always be repaired or removed, even if the rest of the condition became false. The OS version could change due to an OS upgrade, or a service pack removal. This probably is not possible with Windows 7, but it looks like a solid pattern to follow (and it's the recommended way in Wix documentation).

</Condition>

<Media Id="1" Cabinet="media1.cab" EmbedCab="yes"/>

<MajorUpgrade AllowSameVersionUpgrades="yes"
Expand Down