NSIS-OS plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Created page. Why didn't anybody tell me about this precious, and old, plug-in?)
 
m (→‎Plug-in's Readme: (Corrected Windows Server 2008 R2 version information))
 
(5 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{PageAuthor|rainwater}}
== Download Links ==
== Download Links ==
<attach>Nsisos.zip</attach>
<attach>Nsisos.zip</attach>


== Description ==
== Description ==
This plug-in allows you to detect the Windows version.
This plug-in allows you to detect the OS version or platform.


== Plug-in's Readme ==
== Plug-in's Readme ==
Line 12: Line 14:


This software is provided 'as-is', without any express or implied
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
arising from the use of this software.


Permission is granted to anyone to use this software for any purpose,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
including commercial applications, and to alter it and redistribute
freely, subject to the following restrictions:
it freely, subject to the following restrictions:
 
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
 
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
 
3. This notice may not be removed or altered from any source distribution.


1. The origin of this software must not be misrepresented;
  you must not claim that you wrote the original software.
  If you use this software in a product, an acknowledgment in the
  product documentation would be appreciated but is not required.
2. Altered versions must be plainly marked as such,
  and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any distribution.


OS Version Usage Information
OS Version Usage Information
Line 36: Line 35:


Step 2:
Step 2:
The major version is returned to $0 and the minor version is returned to $1.  See below for details on version numbers.
The major version is returned to $0 and the minor version
        is returned to $1.  See below for details on version numbers.




Line 45: Line 45:


Step 2:
Step 2:
The platform is returned into $0.  Possible values are: "win31", "win9x", "winnt", and "unknown".
The platform is returned into $0.  Possible values
        are: "win31", "win9x", "winnt", and "unknown".




Line 58: Line 59:
   Windows 2000 5  
   Windows 2000 5  
   Windows XP 5  
   Windows XP 5  
   Windows .NET Server 5  
   Windows Server 2003 5 (including R2 update)
  Windows Vista 6
  Windows Server 2008  6 (including R2 update)
  Windows 7            6


Minor Version
Minor Version
Line 67: Line 71:
   Windows NT 4.0 0  
   Windows NT 4.0 0  
   Windows 2000 0  
   Windows 2000 0  
   Windows XP 1  
   Windows XP 32-bit 1  
   Windows .NET Server 1  
   Windows XP 64-bit 2
  Windows Server 2003 2 (including R2 update)
  Windows Server 2008  0
  Windows Server 2k8 R2 1
  Windows Vista 0
  Windows 7            1
 
(note: Windows XP x64 and Windows Server 2003 will both return version 5.2)


Example
Example
-------
-------
See example.nsi
 
# Get the OS version
nsisos::osversion
StrCpy $R0 $0
StrCpy $R1 $1
           
# Check our version
StrCmp $R0 "5" WindowsXPPlatform
StrCmp $R0 "6" WindowsVistaPlatform
 
WindowXPPlatform:
MessageBox MB_OK|MB_ICONSTOP "Installation failed: Windows XP or earlier not supported."
Abort
 
WindowVistaPlatform:
 
Also, see example.nsi
</pre>
</pre>


Thanks [[User:Rainwater|Rainwater]] again!
Thanks [[User:rainwater|rainwater]] again!
[[Category:Plugins]]

Latest revision as of 14:45, 12 February 2010

Author: rainwater (talk, contrib)


Download Links

Nsisos.zip (4 KB)

Description

This plug-in allows you to detect the OS version or platform.

Plug-in's Readme

NSIS-OS 1.1

Copyright (C) 2001 Robert Rainwater <rrainwater@yahoo.com>

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented;
   you must not claim that you wrote the original software.
   If you use this software in a product, an acknowledgment in the
   product documentation would be appreciated but is not required.
2. Altered versions must be plainly marked as such,
   and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any distribution.

OS Version Usage Information
----------------------------
Step 1:
	Call osversion

Step 2:
	The major version is returned to $0 and the minor version
        is returned to $1.  See below for details on version numbers.


OS Platform Usage Information
-----------------------------
Step 1:
	Call osplatform

Step 2:
	The platform is returned into $0.  Possible values
        are: "win31", "win9x", "winnt", and "unknown".


Interpreting The Version Numbers
--------------------------------
Major Version:
  Windows 95 		4 
  Windows 98 		4 
  Windows Me 		4 
  Windows NT 3.51 	3 
  Windows NT 4.0 	4 
  Windows 2000 		5 
  Windows XP 		5 
  Windows Server 2003 	5 (including R2 update)
  Windows Vista 	6
  Windows Server 2008   6 (including R2 update)
  Windows 7             6

Minor Version
  Windows 95 		0 
  Windows 98 		10 
  Windows Me 		90 
  Windows NT 3.51 	51 
  Windows NT 4.0 	0 
  Windows 2000 		0 
  Windows XP 32-bit	1 
  Windows XP 64-bit 	2 
  Windows Server 2003 	2 (including R2 update)
  Windows Server 2008   0
  Windows Server 2k8 R2 1
  Windows Vista 	0
  Windows 7             1

(note: Windows XP x64 and Windows Server 2003 will both return version 5.2)

Example
-------

# Get the OS version
nsisos::osversion
StrCpy $R0 $0
StrCpy $R1 $1
            
# Check our version
StrCmp $R0 "5" WindowsXPPlatform
StrCmp $R0 "6" WindowsVistaPlatform

WindowXPPlatform:
MessageBox MB_OK|MB_ICONSTOP "Installation failed: Windows XP or earlier not supported."
Abort

WindowVistaPlatform:

Also, see example.nsi

Thanks rainwater again!