Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Win95cmd Batch enhancer for Windows 95/98/ME users

8 views
Skip to first unread message

William Allen

unread,
Dec 23, 2001, 6:14:48 AM12/23/01
to
Following some email interest in Win95cmd this article describes
some of its features and illustrates some suggested syntax to use
these features in Windows 95/98/ME batch files.

======Notes on Win95cmd.exe

Win95cmd.exe is a Microsoft batch enhancer for Windows 95/98/ME
users who are interested in learning and using some of the enhanced
batch language features in Win2000 (similar enhanced Batch features
are present in Windows XP).

Win95cmd.exe file is available free as a single small ZIP from:
http://www.neuro.gatech.edu/users/cwilson/cygutils/unversioned/consize/

Also free here as part of the MS CAB package: psdk-x86.49.cab
ftp://ftp.microsoft.com/developr/platformsdk/oct2000/psdk-x86.49.cab
(Note: this is a large CAB file and this site is subject to reorganisation)

======

Normal use with Batch files is to shell to it to add its features
to the Batch language, and it needs no "installing" other than
simply placing the WIN95CMD.EXE executable in C:\WINDOWS.

Index to items in this article

====1) Win95cmd example showing how to parse a string in a varible
====2) Input into an environment variable
====3) Escaping characters such as < and > with Win95cmd
====4) FOR IN DO extensions
====5) Win95cmd Batch arithmetic (reference to earlier post)
====6) Creating a Win95cmd custom DVM in Windows 95/98/ME
====7) Some known problems with the Win95cmd custom DVM installation:
====8) Other General Points:


====1) Parse a string

Win95cmd will easily parse variables, to extract substrings.
For help on the extended syntax with variables, at the DOS
prompt in Windows 95/98/ME (with Win95cmd.exe in the path)
type the command:

win95cmd /c set /?

To extract the m characters following the nth character
of VAR, use the syntax %VAR:~4,6%

The following demo shows the syntax to use Win95cmd from
a normal Windows 95/98/ME batch file to recover the six
characters following the fourth character of VAR:

============Screen capture
C:\WORK>ver

Windows 95. [Version 4.00.1111]


C:\WORK>type demo.bat
@ECHO OFF
set VAR=LongStringOfCharacters
win95cmd/c echo SET MID=%%VAR:~4,6%%>TEMP.BAT
FOR %%C IN (CALL DEL) DO %%C temp.bat
ECHO. MID is %MID%

C:\WORK>demo
MID is String
C:\WORK>
============End screen capture

Note the doubled %% signs in the win95cmd line. This is required
to pass the variable properly to the /c child shell in which the
parsing is done. The parsed result is captured in TEMP.BAT and
recovered in the parent shell by executing (then deleting) TEMP.BAT


====2) Input into an environment variable

Read the help under
win95cmd /c set /?
for explanation of the SET /P switch, which allows input
into a variable. The demo below shows how to call a subroutine
in a win95cmd child shell to grab user input and recover it
in the parent shell.

====Begin cut-and-paste (omit this line)
@ECHO OFF
IF (GOTO:)==(%1) %1%2 SUBCALL (Subroutine handler)

:: Call the input subroutine in a Win95cmd child shell
win95cmd /c %0 GOTO: _INPUT VAR
:: Recover the input from the temporary file
FOR %%C IN (CALL DEL) DO %%C %TEMP%.\IN.BAT
ECHO. The input was:%VAR%

GOTO EOF (=Subroutine code follows=)
:_INPUT
:: Any prompting string is set here, eg:"Please input some text:"
SET /P VAR=Please input some text:
:: Capture the variable for return to parent shell
ECHO.SET %3=%VAR%>%TEMP%.\IN.BAT

:EOF (End-of-file)

====End cut-and-paste (omit this line)
To use the code above, cut-and-paste the text between the ==== lines
into a file with extension .BAT and base name of your choice. Lines
that don't begin with two spaces have wrapped in transmission. The
Batch code above was written and tested in the Win9x GUI.


====3) "Escaping" characters such as < and > and so on:

With Win95cmd, the < and > can characters be escaped
and an ECHO command can be enclosed in "quotes"
to escape it from Command.com. Win95cmd removes the
quotes. This provides yet another way of ECHOing <> for
say, HTML, purposes. Demo script:

====Begin cut-and-paste (omit this line)
@ECHO OFF
win95cmd/c "ECHO.^<HTML^>">TEST.HTM
win95cmd/c "ECHO.^<HEAD^> ^<TITLE^> Tiny HTML File ^</TITLE^> ^</HEAD^>">>TEST.HTM
win95cmd/c "ECHO.^<BODY^>">>TEST.HTM
win95cmd/c "ECHO.^<CENTER^> This is a tiny HTML file. ^</CENTER^>">>TEST.HTM
win95cmd/c "ECHO.^</BODY^>">>TEST.HTM
win95cmd/c "ECHO.^</HTML^>">>TEST.HTM

====End cut-and-paste (omit this line)
To use the code above, cut-and-paste the text between the ==== lines
into a file with extension .BAT and base name of your choice. Lines
that don't begin with two spaces have wrapped in transmission. The
Batch code above was written and tested in the Win9x GUI with
Win95cmd.exe placed in the system PATH.

============Screen capture in Windows 95 with above as DEMO.BAT
C:\WORK>ver

Windows 95. [Version 4.00.1111]


C:\WORK>demo
C:\WORK>type test.htm
<HTML>
<HEAD> <TITLE> Tiny HTML File </TITLE> </HEAD>
<BODY>
<CENTER> This is a tiny HTML file. </CENTER>
</BODY>
</HTML>

C:\WORK>
============End screen capture


====4) Extensions to the FOR IN DO command
Win95cmd allows most (but not all) of the Windows 2000 extensions
to the FOR IN DO command to be used.

At a DOS prompt in Windows 95/98/ME (with win95cmd.exe in the PATH)
type the command:
win95cmd /c for /?
for extensive help and examples of syntax.

Particularly useful are:
for /L to enable start step stop counting
and
for /R to walk the entire folder tree rooted at any folder


====5) Batch arithmetic

Win95cmd allows Windows 95/98/ME users to carry out the enhanced
SET arithmetic functions available in Windows 2000.

For details and a demo script showing how to use Win95cmd to perform
Batch arithemtic from a normal Windows 95/98/ME Batch file, click on
this link to previous post:

Batch arithmetic with the Win95cmd Batch enhancer
http://groups.google.com/groups?selm=9vdkh4$efe02$1...@ID-55970.news.dfncis.de
Date: 14 Dec 2001


====6) Creating a Win95cmd custom DVM in Windows 95/98/ME

For study purposes, the following simple kludge install is useful while
learning about Win95cmd. Once installed this way, try typing
FOR /?
and
SET /?
for the huge amount of documentation on the many additional
features available with this useful free enhancement.

First, create a Windows 95/98/ME custom DVM as follows:
(a) Right-click on blank area of Desktop and click "New"
(b) Click "Shortcut"
(c) Fill in the command line box with C:\WINDOWS\COMMAND.COM
(d) Click Next, fill in name: Win95Cmd Custom DVM, click "Finish"
(e) With Explorer, make a working folder, say C:\WRK2
(f) In say, C:\WINDOWS\COMMAND folder, create a Batch file
====Start cut-and-paste (omit this line)
@ECHO OFF
C:\WINDOWS\WIN95CMD.EXE /k CLS
====End cut-and-paste (omit this line)
Call the file C:\WINDOWS\COMMAND\WIN95CMD.BAT

(g) Right click the Win95Cmd Custom DVM shortcut, and click "Properties"
(h) In Program Tab, in field "Working" enter your new folder
(whatever you called it, say C:\WRK2)
(i) In Program Tab, in field "Batch file" enter the specification
of the small WIN95CMD.BAT batch file you created:
C:\WINDOWS\COMMAND\WIN95CMD.BAT

(j) In the Miscellaneous Tab of the shortcut, "Other" section,
make sure "Fast pasting" is unchecked. This allows normal pasting
to the WIN95CMD DVM, which is obviously necessary for quick
learning. This enables cut-and-paste to the Win95cmd window in
the usual way.


====7) Some known problems with the above installation:

a) CapsLock works as a general ShiftLock so non-alpha keys
are out-shifted too.

b) The pipe character doesn't appear to be translated properly
so piping isn't handled

c) FOR IN DO parsing of files isn't handled, but text strings can
be parsed.

d) DOSKEY starts in overtype mode regardless of system setting.

e) The internal WIN95CMD TYPE command is Unicode compliant,
following the Win2000 standard. You can avoid Unicode interpretation
by using redirection to a file. To display a file to screen
without Unicode interpretation, use redirection to CON.
TYPE FILENAME.EXT>CON

In general, you should regard Win95cmd set up this way as a
useful educational tool, but practical uses are numerous.

====8) Other General Points:
a)
The above method allows quite a number of features, particularly
many of the FOR IN DO extensions, to be used.
In the custom DVM, type FOR /? for the huge list of extra
FOR IN DO features
and type SET /? for the extensions to the SET command

In general most of the InternalCommand /? help is worth reading.

b)
Some _internal_ commands generate ERRORLEVELs and the
current ERRORLEVEL can be echoed from the same-name
system variable:
ECHO. %ERRORLEVEL%

Note that a missing command will generate a high ERRORLEVEL
(above 255) which can nevertheless be tested with IF ERRORLEVEL.

============Screen capture in Win95cmd custom DMV in Windows 95
C:\WRK2>choicex
'choicex' is not recognized as an internal or external command,
operable program or batch file.

C:\WRK2>echo.%errorlevel%
9009

C:\WRK2>
============End screen capture

Note that in a Win95cmd shell ERRORLEVELs are NOT interpreted
modulo 256, and (_unlike_ a COMMAND.COM shell) the command
IF ERRORLEVEL 9009 _is_not_ the same as IF ERRORLEVEL 49
(9009=49 mod 256)

--
(pp) William Allen


Charles Dye

unread,
Dec 23, 2001, 8:07:43 PM12/23/01
to
On Sun, 23 Dec 2001 11:14:48 -0000, "William Allen"
<NGr...@mayfly13.fsnet.co.uk> wrote:

>====3) "Escaping" characters such as < and > and so on:
>
>With Win95cmd, the < and > can characters be escaped
>and an ECHO command can be enclosed in "quotes"
>to escape it from Command.com. Win95cmd removes the
>quotes. This provides yet another way of ECHOing <> for
>say, HTML, purposes. Demo script:
>
>====Begin cut-and-paste (omit this line)
> @ECHO OFF
> win95cmd/c "ECHO.^<HTML^>">TEST.HTM
> win95cmd/c "ECHO.^<HEAD^> ^<TITLE^> Tiny HTML File ^</TITLE^> ^</HEAD^>">>TEST.HTM
> win95cmd/c "ECHO.^<BODY^>">>TEST.HTM
> win95cmd/c "ECHO.^<CENTER^> This is a tiny HTML file. ^</CENTER^>">>TEST.HTM
> win95cmd/c "ECHO.^</BODY^>">>TEST.HTM
> win95cmd/c "ECHO.^</HTML^>">>TEST.HTM
>
>====End cut-and-paste (omit this line)

Actually, the literal-character escapes (the carets) in the
above examples are redundant. Since the redirection tokens
are inside double quotes, there is no need to escape them.

--
Charles Dye ras...@highfiber.com


William Allen

unread,
Dec 24, 2001, 3:53:52 AM12/24/01
to
"Charles Dye" wrote in message

> On Sun, 23 Dec 2001 11:14:48 -0000, "William Allen" wrote:
>
> >====3) "Escaping" characters such as < and > and so on:
> >
> >With Win95cmd, the < and > can characters be escaped
> >and an ECHO command can be enclosed in "quotes"
> >to escape it from Command.com. Win95cmd removes the
> >quotes. This provides yet another way of ECHOing <> for
> >say, HTML, purposes. Demo script:
> >
> >====Begin cut-and-paste (omit this line)
> > @ECHO OFF
> > win95cmd/c "ECHO.^<HTML^>">TEST.HTM

...snip


> Actually, the literal-character escapes (the carets) in the
> above examples are redundant. Since the redirection tokens
> are inside double quotes, there is no need to escape them.

No. That is not so. Both quotes and carets are required. The
screen capture below shows that without the use of the
caret escape characters, the syntax fails:

============Screen capture in Windows 95 with win95cmd.exe in PATH
C:\WORK>ver

Windows 95. [Version 4.00.1111]


C:\WORK>win95cmd/c "ECHO.^<HTML^>">TEST.HTM

C:\WORK>type test.htm
<HTML>

C:\WORK>win95cmd/c "ECHO.<HTML>">TEST.HTM
The syntax of the command is incorrect.

C:\WORK>
============End screen capture

--
(pp) William Allen


Charles Dye

unread,
Dec 24, 2001, 5:28:18 AM12/24/01
to
On Mon, 24 Dec 2001 08:53:52 -0000, "William Allen"
<NGr...@mayfly13.fsnet.co.uk> wrote:

>"Charles Dye" wrote in message

>> Actually, the literal-character escapes (the carets) in the


>> above examples are redundant. Since the redirection tokens
>> are inside double quotes, there is no need to escape them.
>
>No. That is not so. Both quotes and carets are required. The
>screen capture below shows that without the use of the
>caret escape characters, the syntax fails:

My mistake. It worked for me without the carets because
I had the auxiliary ECHO command outside of the double
quotes, which is legal syntax but clearly the Wrong Thing.
My apologies for the misstatement.

--
Charles Dye ras...@highfiber.com


William Allen

unread,
Dec 24, 2001, 6:48:13 AM12/24/01
to
"Charles Dye" wrote in message
...snip

> My mistake. It worked for me without the carets because
> I had the auxiliary ECHO command outside of the double
> quotes, which is legal syntax but clearly the Wrong Thing.

The problem there is that although the syntax is accepted,
the "quotes" are installed in the file created:

============Screen capture


C:\WORK>win95cmd/c ECHO."<HTML>">TEST.HTM

C:\WORK>type test.htm
"<HTML>"

C:\WORK>REM Quotes were not removed

C:\WORK>win95cmd/c "ECHO.^<HTML^>">TEST.HTM

C:\WORK>type test.htm
<HTML>

C:\WORK>REM Quotes _were_ removed

C:\WORK>
============End screen capture

However, the ECHO (and SET) outside "quotes" are useful in this Win95cmd
demo, which shows how environment variables containing = < > and |
can be used in a Win95cmd Subroutine called within an ordinary Windows
95/98/ME batch file. As long as the variables concerned are used
within the Subroutine, there is no need to use the Synthetic Variable
method (see reference) for such variables.

====Begin cut-and-paste (omit this line)
@ECHO OFF

IF (GOTO:)==(%1) %1%2 (Subroutine handler)

win95cmd/c %0 GOTO: _DEMO

GOTO EOF (=Subroutine code follows=)

:_DEMO

:: "Quotes" allow variable to be SET, but aren't placed in the variable
SET "V1=String with = and, <, > and |"
ECHO. "V1=[%V1%] with quotes only to facilitate ECHOing"

:EOF (End-of-file)

====End cut-and-paste (omit this line)

To use the code above, cut-and-paste the text between the ==== lines
into a file with extension .BAT and base name of your choice. Lines
that don't begin with two spaces have wrapped in transmission. The
Batch code above was written and tested in the Win9x GUI with

Win95cmd.exe in the PATH

============Screen capture with above pasted as DEMO.BAT
C:\WORK>demo
"V1=[String with = and, <, > and |] with quotes only to facilitate ECHOing"


C:\WORK>
============End screen capture

--
(pp) William Allen

For details of the Synthetic Environment variable technique, see:
Several environment variables each with the same name
http://groups.google.com/groups?selm=8vg2vg$4fsnb$1...@ID-55970.news.dfncis.de
Date: 22 Nov 2000


Rik D'haveloose

unread,
Dec 23, 2001, 9:01:19 AM12/23/01
to
William Allen wrote

> Following some email interest in Win95cmd this article describes
> some of its features and illustrates some suggested syntax to use
> these features in Windows 95/98/ME batch files.
>
> ======Notes on Win95cmd.exe

I still consider such (10 kB) posting a "detailed" handling of something
which may be mentioned here (but not in detail).....
Hope you can follow the agreed netetiquette (like others do here), and
why the news:alt.msdos.batch.Nt was created for.

--
TUF Greetings from Rumbeke
Belgium


Clay Calvert

unread,
Dec 25, 2001, 8:34:54 PM12/25/01
to

Win95cmd is not a tool for NT.

Clay Calvert
Replace "W" with "L" in email.

Outsider

unread,
Dec 26, 2001, 2:06:31 AM12/26/01
to

So?

It is an NT commandline emulator and should be discussed in an NT group
just as 4DOS should be discussed in news:comp.os.msdos.4dos.


--
<!-Outsider//->
MS-DOS 6.22, Windows for Workgroups 3.11, Netscape Communicator 4.08
Line Counting --a programmer's disease.

0 new messages