-
Notifications
You must be signed in to change notification settings - Fork 3
/
getWindowsVersion.cmd
135 lines (125 loc) · 5.14 KB
/
getWindowsVersion.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION&::(Don't pollute the global environment with the following)
SET $NAME=%~n0
SET $DESCRIPTION=Reading Windows version info from registry database
SET $AUTHOR=Erik Bachmann, ClicketyClick.dk [ErikBachmann@ClicketyClick.dk]
SET $SOURCE=%~f0
::@(#)NAME
::@(-) The name of the command or function, followed by a one-line description of what it does.
::@(#) %$NAME% -- %$DESCRIPTION%
::@(#)
::@(#)SYNOPSIS
::@(-) In the case of a command, a formal description of how to run it and what command line options it takes.
::@(-) For program functions, a list of the parameters the function takes and which header file contains its definition.
::@(-)
::@(#) CALL %$NAME%
::@(#)
::@(#)OPTIONS
::@(-) Flags, parameters, arguments (NOT the Monty Python way)
::@(#) -h Help page
::@(#)
::@ (#)
::@(#)DESCRIPTION
::@(-) A textual description of the functioning of the command or function.
::@(#) Reads Microsoft Window registry entries for Product Name,
::@(#) Verision, Build, CSD [Service Pack] and Installation Type
::@(#) Verbose the full name and set the following env vars:
::@(#) #HKEY_LOCAL_MACHINE.CSDVersion=Service Pack 1
::@(#) #HKEY_LOCAL_MACHINE.CurrentBuild=7601
::@(#) #HKEY_LOCAL_MACHINE.CurrentVersion=6.1
::@(#) #HKEY_LOCAL_MACHINE.InstallationType=Client
::@(#) #HKEY_LOCAL_MACHINE.ProductName=Windows 7 Professional
::@(#)
::@(#)EXAMPLES
::@(-) Some examples of common usage.
::@(#) CALL WindowsVersion.cmd
::@(#)
::@(#) Windows 7 Professional, Service Pack 1 [v. 6.1 Build. 7601] Client
::@(#)
::@(#) set #
::@(#) #HKEY_LOCAL_MACHINE.CSDVersion=Service Pack 1
::@(#) #HKEY_LOCAL_MACHINE.CurrentBuild=7601
::@(#) #HKEY_LOCAL_MACHINE.CurrentVersion=6.1
::@(#) #HKEY_LOCAL_MACHINE.InstallationType=Client
::@(#) #HKEY_LOCAL_MACHINE.ProductName=Windows 7 Professional
::@(#)
::@(#)LIMITATIONS
::@(#) The ProcessBarMarker CANNOT be a digit due to redirection rules in
::@(#) DOS [Default=@]
::@(#) Avoid other special characters like ampersand or pipe
::@(#)
::@(#)EXIT STATUS
::@(-) Exit status / errorlevel is 0 if OK, otherwise 1+.
::@(#) Exit status is 0 if any matches were found, otherwise 1.
::@(#)
::@ (#)ENVIRONMENT
::@(-) Variables affected
::@ (#)
::@ (#)
::@ (#)FILES,
::@(-) Files used, required, affected
::@ (#)
::@ (#)
::@ (#)BUGS / KNOWN PROBLEMS
::@(-) If any known
::@ (#)
::@(#)REQUIRES
::@(-) Dependecies
::@(#) _Debug.cmd Setting up debug environment for batch scripts
::@(#) _GetOpt.cmd Parse command line options and create environment vars
::@(#) _registry.read_string.cmd
::@(#)
::@ (#)SEE ALSO
::@(-) A list of related commands or functions.
::@(#) _registry.read_string
::@ (#)
::@ (#)REFERENCE
::@(-) References to inspiration, clips and other documentation
::@ (#) Author:
::@ (#) URL:
::@ (#)
::@(#)
::@(#)SOURCE
::@(-) Where to find this source
::@(#) %$Source%
::@(#)
::@ (#)AUTHOR
::@(-) Who did what
::@ (#) %$AUTHOR%
::*** HISTORY **********************************************************
::SET $VERSION=YYYY-MM-DD&SET $REVISION=hh:mm:ss&SET $COMMENT=Init Description/Initials [xx.xxx]
::SET $VERSION=2008-09-04&SET $REVISION=12:04:16&SET $COMMENT= [01.200]
::SET $VERSION=2010-10-14&SET $REVISION=14:27:00&SET $COMMENT=Initial/ErikBachmann [01.000]
::SET $VERSION=2010-10-20&SET $REVISION=17:15:00&SET $COMMENT=Addding $Source/ErikBachmann [01.001]
::SET $VERSION=2014-01-07&SET $REVISION=17:27:00&SET $COMMENT=Reading from reg/ErikBachmann [01.010]
::SET $VERSION=2015-02-19&SET $REVISION=03:01:53&SET $COMMENT=Autoupdate / ErikBachmann
::SET $VERSION=2015-03-23&SET $REVISION=10:35:00&SET $COMMENT=Fixed return variable: %~n0 / ErikBachmann
::SET $VERSION=2015-10-08&SET $REVISION=11:20:00&SET $COMMENT=GetOpt: Calling usage on -h and exit on error / ErikBachmann
SET $VERSION=2016-03-14&SET $REVISION=10:00:00&SET $COMMENT=Set "%~dp0\ prefix on function calls / ErikBachmann
::**********************************************************************
::@(#)(c)%$Version:~0,4% %$Author%
::**********************************************************************
CALL "%~dp0\_DEBUG"
CALL "%~dp0\_Getopt" %*&IF ERRORLEVEL 1 EXIT /B 1
ENDLOCAL
:INIT
::SETLOCAL
IF NOT DEFINED $NAME SET $NAME=HKEY_LOCAL_MACHINE
:MAIN
CALL "%~dp0\_GetOpt" %*
CALL "%~dp0\_Debug"
SET $WINVERNAME=UNKNOWN
SET $WINVERNO=UNKNOWN
SET _R_=_registry.read_string.cmd "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
CALL %_R_% "ProductName"
CALL %_R_% "CurrentVersion"
CALL %_R_% "CurrentBuild"
CALL %_R_% "CSDVersion"
CALL %_R_% "InstallationType"
CALL SET getWindowsVersion=%%#%$NAME%.ProductName%%, !#%$NAME%.CSDVersion! [v. %%#%$NAME%.CurrentVersion%% Build. %%#%$NAME%.CurrentBuild%%] %%#%$NAME%.InstallationType%%
CALL %_VERBOSE_% %getWindowsVersion%
::ENDLOCAL&CALL SET %~n0=%getWindowsVersion%
::EndLocal&CALL SET #%$NAME%.ProductName=%%#%$NAME%.ProductName%%
::%%#%$NAME%.ProductName%%, !#%$NAME%.CSDVersion! [v. %%#%$NAME%.CurrentVersion%% Build. %%#%$NAME%.CurrentBuild%%] %%#%$NAME%.InstallationType%%
GOTO :EOF
::*** End of File ******************************************************