cmd.net: Querying the .Net Environment

As described in my introductory post on cmd.net, the utilities contained in the collection should make use of .Net functionality wherever possible.

The utilities provide command-line switches to select the encoding of the input and output streams (-in for stdin or Console.In, and -out for stdout or Console.Out), and the culture info (-ci) for NLS-sensitive operations.

How to find out the valid values for these switches?

netenv

The netenv utility displays the current input and output stream encodings and code pages, as well as the current culture:

input code page: 850
input Windows code page: 1252
input encoding: Western European (DOS)
output code page: 850
output Windows code page: 1252
output encoding: Western European (DOS)
culture: de-AT
LCID: 3079
culture display name: German (Austria)

Changing the culture info to English using the -ci switch

netenv -ci en-us

generates this output

input code page: 850
input Windows code page: 1252
input encoding: Western European (DOS)
output code page: 850
output Windows code page: 1252
output encoding: Western European (DOS)
culture: en-US
LCID: 1033
culture display name: English (United States)

listci

To query all culture infos implemented in .Net, use the listci command. This will display the LCID, name, type, and display name of all CultureInfos.

listci | find " en"

returns

    9 en          N W   English
 1033 en-US        SW   English (United States)
 2057 en-GB        SW   English (United Kingdom)
 3081 en-AU        SW   English (Australia)
 4105 en-CA        SW   English (Canada)
 5129 en-NZ        SW   English (New Zealand)
 6153 en-IE        SW   English (Ireland)
 7177 en-ZA        SW   English (South Africa)
 8201 en-JM        SW   English (Jamaica)
 9225 en-029       SW   English (Caribbean)
10249 en-BZ        SW   English (Belize)
11273 en-TT        SW   English (Trinidad and Tobago)
12297 en-ZW        SW   English (Zimbabwe)
13321 en-PH        SW   English (Republic of the Philippines)
16393 en-IN        SW   English (India)
17417 en-MY        SW   English (Malaysia)
18441 en-SG        SW   English (Singapore)

The list is sorted by the LCID by default, and can be changed using the -o switch. The -t switch restricts the list to certain CultureTypes.

listenc

To query all encodings implemented in .Net, use the listenc command. This will display the code page, name, and display name of all Encodings.

listenc | find "Unicode"

returns

 1200 utf-16                  Unicode
 1201 utf-16BE                Unicode (Big-Endian)
12000 utf-32                  Unicode (UTF-32)
12001 utf-32BE                Unicode (UTF-32 Big-Endian)
65000 utf-7                   Unicode (UTF-7)
65001 utf-8                   Unicode (UTF-8)

The list ist sorted by the code page (CP) by default, and can be changed using the -o switch.

netver

The command netver lists all installed versions of the .Net framework.

.Net Framework Versions
v2.0.50727: Version 2.0.50727.4927 SP 2 installed
v2.0.50727/1031: Version 2.0.50727.4927 SP 2 installed
v3.0: Version 3.0.30729.4926 SP 2 installed
v3.0/Setup: Version 3.0.30729.4926
v3.0/Setup/1031: Version 3.0.30729.4926 SP 2 installed
v3.0/Setup/Windows Communication Foundation: Version 3.0.4506.4926
v3.0/Setup/Windows Presentation Foundation: Version 3.0.6920.4902
v3.5: Version 3.5.30729.4926 SP 1 installed
v3.5/1031: Version 3.5.30729.4926 SP 1 installed
v4/Client: Version 4.0.30319 installed
v4/Client/1033: Version 4.0.30319 installed
v4/Full: Version 4.0.30319 installed
v4/Full/1033: Version 4.0.30319 installed

Generic command-line switches

All utilities use the same command-line parser, and therefore provide generic functionality for command-line switches:

Command-line switches can be prefixed by “-” or “/” (dash or slash), and switches are typically case-insensitive except if case-sensitive switches are defined.

The “-?” switch (alternatives /?, -h, /h) display the implemented switches and allowed or required parameters. If the command requires switches and/or parameters, the help information is displayed if no parameters are present.

The -in and -out switches set the stream encodings where applicable.

The -ci switch sets the culture info where applicable.

The first version of cmd.net is available for download here, and contains the commands described in this post.

Advertisements

3 Responses to cmd.net: Querying the .Net Environment

  1. […] first version of cmd.net is available for download here, and contains the commands listci, listenc, netenv, netver, datetime, df, enc, guid, tee, uniq, xslt. Possibly related posts: (automatically generated)Biggest […]

  2. […] enc command converts an encoded stdin to a different encoding on stdout using the -in [encoding] and -out [encoding] command-line […]

  3. […] usual, the -in and -out switches define the encodings of stdin and […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: