Check file version command line windows

Find windows OS version from command line

Windows has command line utilities that show us the version of the Windows OS running on the computer, including the service pack number. There are multiple CMD commands that help with finding this, you can pick the one that suits your need. Ver command can show you the OS version whereas Systeminfo command can additionally give you service pack, OS edition and build number etc.

Find OS Version and Service Pack number from CMD

As you can see above, ver command shows only OS version but not the service pack number. We can find service pack number as well with Systeminfo command. Systeminfo dumps lot of other information too, which we can filter out using findstr command.

This command works on XP, Vista and Windows 7 and on Server editions also. Find below example for Win7.

In case of Windows 7 SP1, the output would be slightly different as below.

If you want to print more details, then you can use just ‘OS’ in the findstr search pattern. See example below for Server 2008.

Check Windows version using WMIC command

Run the below WMIC command to get OS version and the service pack number.

Example on Windows 7:

If you want to find just the OS version, you can use ver command. Open command window and execute ver command. But note that this does not show service pack version.

This command does not show version on a Windows 7 system.

CheckDisk¶

CheckDisk can check various file and disk related things.

CheckDisk is provides two disk related checks one for checking size of drives and the other for checking status of files and folders.

Please note that UNC and network paths are only available in each session meaning a user mounted share will not be visible to NSClient++ (since services run in their own session). But as long as NSClient++ can access the share you can still check it as you specify the UNC path. In other words the following will NOT work: check_drivesize drive=m: But the following will: check_drivesize drive=\\myserver\\mydrive

Queries¶

A quick reference for all available queries (check commands) in the CheckDisk module.

List of commands:

A list of all available queries (check commands)

Command Description
check_drivesize Check the size (free-space) of a drive or volume.
check_files Check various aspects of a file and/or folder.
checkdrivesize Legacy version of check_drivesize
checkfiles Legacy version of check_drivesize

check_drivesize¶

Check the size (free-space) of a drive or volume.

Sample Commands¶

To edit these sample please edit this page

To check the size of the C:\ drive and make sure it has atleast 10% free space::

To check the size of all the drives and make sure it has at least 10% free space::

To check the size of all the drives and display all values, not just problems::

To check the size of all the drives and return the value in gigabytes. By default units on performance data will be scaled to “something appropriate”::

To check the size of a mounted volume (c:\volume_test) and make sure it has 1M free space warn if free space is less then 10M::

To check the size of all volumes and make sure they have 1M space free::

To check the size of all fixed and network drives and make sure they have at least 1gig free space::

To check all fixed and network drives but ignore C and F::

Default via NRPE:

Command-line Arguments¶

Option Default Value Description
filter mounted = 1 Filter which marks interesting items.
warning used > 80% Filter which marks items which generates a warning state.
warn Short alias for warning
critical used > 90% Filter which marks items which generates a critical state.
crit Short alias for critical.
ok Filter which marks items which generates an ok state.
debug N/A Show debugging information in the log
show-all N/A Show details for all matches regardless of status (normally details are only showed for warnings and criticals).
empty-state unknown Return status to use when nothing matched filter.
perf-config Performance data generation configuration
escape-html N/A Escape any characters to prevent HTML encoding
help N/A Show help screen (this screen)
help-pb N/A Show help screen as a protocol buffer payload
show-default N/A Show default values for a given command
help-short N/A Show help screen (short format).
top-syntax $ $ Top level syntax.
ok-syntax %(status) All %(count) drive(s) are ok ok syntax.
empty-syntax %(status): No drives found Empty syntax.
detail-syntax $: $/$ used Detail level syntax.
perf-syntax $ Performance alias syntax.
drive The drives to check.
ignore-unreadable N/A DEPRECATED (manually set filter instead) Ignore drives which are not reachable by the current user.
mounted N/A DEPRECATED (this is now default) Show only mounted rives i.e. drives which have a mount point.
magic Magic number for use with scaling drive sizes.
exclude A list of drives not to check
total N/A Include the total of all matching drives
filter:

Filter which marks interesting items. Interesting items are items which will be included in the check. They do not denote warning or critical state instead it defines which items are relevant and you can remove unwanted items.

Default Value: mounted = 1

warning:

Filter which marks items which generates a warning state. If anything matches this filter the return status will be escalated to warning.

Default Value: used > 80%

critical:

Filter which marks items which generates a critical state. If anything matches this filter the return status will be escalated to critical.

Default Value: used > 90%

Filter which marks items which generates an ok state. If anything matches this any previous state for this item will be reset to ok.

empty-state:

Return status to use when nothing matched filter. If no filter is specified this will never happen unless the file is empty.

Default Value: unknown

perf-config:

Performance data generation configuration TODO: obj ( key: value; key: value) obj (key:valuer;key:value)

top-syntax:

Top level syntax. Used to format the message to return can include text as well as special keywords which will include information from the checks. To add a keyword to the message you can use two syntaxes either $ or %(keyword) (there is no difference between them apart from $<> can be difficult to excpae on linux).

ok-syntax:

ok syntax. DEPRECATED! This is the syntax for when an ok result is returned. This value will not be used if your syntax contains %(list) or %(count).

Default Value: %(status) All %(count) drive(s) are ok

empty-syntax:

Empty syntax. DEPRECATED! This is the syntax for when nothing matches the filter.

Default Value: %(status): No drives found

detail-syntax:

Detail level syntax. Used to format each resulting item in the message. %(list) will be replaced with all the items formated by this syntax string in the top-syntax. To add a keyword to the message you can use two syntaxes either $ or %(keyword) (there is no difference between them apart from $<> can be difficult to excpae on linux).

perf-syntax:

Performance alias syntax. This is the syntax for the base names of the performance data.

drive:

The drives to check. Multiple options can be used to check more then one drive or wildcards can be used to indicate multiple drives to check. Examples: drive=c, drive=d:, drive=*, drive=all-volumes, drive=all-drives

ignore-unreadable:

DEPRECATED (manually set filter instead) Ignore drives which are not reachable by the current user. For instance Microsoft Office creates a drive which cannot be read by normal users.

Filter keywords¶

Option Description
count Number of items matching the filter. Common option for all checks.
crit_count Number of items matched the critical criteria. Common option for all checks.
crit_list A list of all items which matched the critical criteria. Common option for all checks.
detail_list A special list with critical, then warning and finally ok. Common option for all checks.
drive Technical name of drive
drive_or_id Drive letter if present if not use id
drive_or_name Drive letter if present if not use name
erasable 1 (true) if drive is erasable
flags String representation of flags
free Shorthand for total_free (Number of free bytes)
free_pct Shorthand for total_free_pct (% free space)
hotplug 1 (true) if drive is hotplugable
id Drive or id of drive
letter Letter the drive is mountedd on
list A list of all items which matched the filter. Common option for all checks.
media_type Get the media type
mounted Check if a drive is mounted
name Descriptive name of drive
ok_count Number of items matched the ok criteria. Common option for all checks.
ok_list A list of all items which matched the ok criteria. Common option for all checks.
problem_count Number of items matched either warning or critical criteria. Common option for all checks.
problem_list A list of all items which matched either the critical or the warning criteria. Common option for all checks.
readable 1 (true) if drive is readable
removable 1 (true) if drive is removable
size Total size of drive
status The returned status (OK/WARN/CRIT/UNKNOWN). Common option for all checks.
total Total number of items. Common option for all checks.
total_free Number of free bytes
total_free_pct % free space
total_used Number of used bytes
total_used_pct % used space
type Type of drive
used Number of used bytes
used_pct Shorthand for total_used_pct (% used space)
user_free Free space available to user (which runs NSClient++)
user_free_pct % free space available to user
user_used Number of used bytes (related to user)
user_used_pct % used space available to user
warn_count Number of items matched the warning criteria. Common option for all checks.
warn_list A list of all items which matched the warning criteria. Common option for all checks.
writable 1 (true) if drive is writable

check_files¶

Check various aspects of a file and/or folder.

Sample Commands¶

To edit these sample please edit this page

Performance¶

Order is somewhat important but mainly in the fact that some operations are more costly then others. For instance line_count requires us to read and count the lines in each file so choosing between the following: Fast version: filter=creation 100

Slow version: filter=line_count > 100 and creation

The first one will be significantly faster if you have a thousand old files and 3 new ones.

On the other hand in this example filter=creation 100k swapping them would not be noticeable.

Checking versions of .exe files¶

Using the line count with limited recursion:¶

Check file sizes¶

Command-line Arguments¶

Option Default Value Description
filter Filter which marks interesting items.
warning Filter which marks items which generates a warning state.
warn Short alias for warning
critical Filter which marks items which generates a critical state.
crit Short alias for critical.
ok Filter which marks items which generates an ok state.
debug N/A Show debugging information in the log
show-all N/A Show details for all matches regardless of status (normally details are only showed for warnings and criticals).
empty-state unknown Return status to use when nothing matched filter.
perf-config Performance data generation configuration
escape-html N/A Escape any characters to prevent HTML encoding
help N/A Show help screen (this screen)
help-pb N/A Show help screen as a protocol buffer payload
show-default N/A Show default values for a given command
help-short N/A Show help screen (short format).
top-syntax $: $/$ files ($) Top level syntax.
ok-syntax %(status): All %(count) files are ok ok syntax.
empty-syntax No files found Empty syntax.
detail-syntax $

Detail level syntax.
perf-syntax $ Performance alias syntax.
path The path to search for files under.
file Alias for path.
paths A comma separated list of paths to scan
pattern . The pattern of files to search for (works like a filter but is faster and can be combined with a filter).
max-depth Maximum depth to recurse
total filter Include the total of either (filter) all files matching the filter or (all) all files regardless of the filter
filter:

Filter which marks interesting items. Interesting items are items which will be included in the check. They do not denote warning or critical state instead it defines which items are relevant and you can remove unwanted items.

warning:

Filter which marks items which generates a warning state. If anything matches this filter the return status will be escalated to warning.

critical:

Filter which marks items which generates a critical state. If anything matches this filter the return status will be escalated to critical.

Filter which marks items which generates an ok state. If anything matches this any previous state for this item will be reset to ok.

empty-state:

Return status to use when nothing matched filter. If no filter is specified this will never happen unless the file is empty.

Default Value: unknown

perf-config:

Performance data generation configuration TODO: obj ( key: value; key: value) obj (key:valuer;key:value)

top-syntax:

Top level syntax. Used to format the message to return can include text as well as special keywords which will include information from the checks. To add a keyword to the message you can use two syntaxes either $ or %(keyword) (there is no difference between them apart from $<> can be difficult to excpae on linux).

ok-syntax:

ok syntax. DEPRECATED! This is the syntax for when an ok result is returned. This value will not be used if your syntax contains %(list) or %(count).

Default Value: %(status): All %(count) files are ok

empty-syntax:

Empty syntax. DEPRECATED! This is the syntax for when nothing matches the filter.

Default Value: No files found

detail-syntax:

Detail level syntax. Used to format each resulting item in the message. %(list) will be replaced with all the items formated by this syntax string in the top-syntax. To add a keyword to the message you can use two syntaxes either $ or %(keyword) (there is no difference between them apart from $<> can be difficult to excpae on linux).

perf-syntax:

Performance alias syntax. This is the syntax for the base names of the performance data.

The path to search for files under. Notice that specifying multiple path will create an aggregate set you will not check each path individually.In other words if one path contains an error the entire check will result in error.

pattern:

The pattern of files to search for (works like a filter but is faster and can be combined with a filter).

total:

Include the total of either (filter) all files matching the filter or (all) all files regardless of the filter

Default Value: filter

Filter keywords¶

Option Description
access Last access time
access_l Last access time (local time)
access_u Last access time (UTC)
age Seconds since file was last written
count Number of items matching the filter. Common option for all checks.
creation When file was created
creation_l When file was created (local time)
creation_u When file was created (UTC)
crit_count Number of items matched the critical criteria. Common option for all checks.
crit_list A list of all items which matched the critical criteria. Common option for all checks.
detail_list A special list with critical, then warning and finally ok. Common option for all checks.
file The name of the file
filename The name of the file
line_count Number of lines in the file (text files)
list A list of all items which matched the filter. Common option for all checks.
name The name of the file
ok_count Number of items matched the ok criteria. Common option for all checks.
ok_list A list of all items which matched the ok criteria. Common option for all checks.
path Path of file
problem_count Number of items matched either warning or critical criteria. Common option for all checks.
problem_list A list of all items which matched either the critical or the warning criteria. Common option for all checks.
size File size
status The returned status (OK/WARN/CRIT/UNKNOWN). Common option for all checks.
total Total number of items. Common option for all checks.
type Type of item (file or dir)
version Windows exe/dll file version
warn_count Number of items matched the warning criteria. Common option for all checks.
warn_list A list of all items which matched the warning criteria. Common option for all checks.
write Alias for written
written When file was last written to
written_l When file was last written to (local time)
written_u When file was last written to (UTC)

checkdrivesize¶

Legacy version of check_drivesize

Command-line Arguments¶

Option Default Value Description
help N/A Show help screen (this screen)
help-pb N/A Show help screen as a protocol buffer payload
show-default N/A Show default values for a given command
help-short N/A Show help screen (short format).
CheckAll true Checks all drives.
CheckAllOthers true Checks all drives turns the drive option into an exclude option.
Drive The drives to check
FilterType The type of drives to check fixed, remote, cdrom, ramdisk, removable
perf-unit Force performance data to use a given unit prevents scaling which can cause problems over time in some graphing solutions.
ShowAll short Configures display format (if set shows all items not only failures, if set to long shows all cores).
MaxWarn Maximum value before a warning is returned.
MaxCrit Maximum value before a critical is returned.
MinWarn Minimum value before a warning is returned.
MinCrit Minimum value before a critical is returned.
MaxWarnFree Maximum value before a warning is returned.
MaxCritFree Maximum value before a critical is returned.
MinWarnFree Minimum value before a warning is returned.
MinCritFree Minimum value before a critical is returned.
MaxWarnUsed Maximum value before a warning is returned.
MaxCritUsed Maximum value before a critical is returned.
MinWarnUsed Minimum value before a warning is returned.
MinCritUsed Minimum value before a critical is returned.
CheckAll:

Checks all drives.

Default Value: true

CheckAllOthers:

Checks all drives turns the drive option into an exclude option.

Default Value: true

ShowAll:

Configures display format (if set shows all items not only failures, if set to long shows all cores).

Читайте также:  File permission windows server
Оцените статью