Index | -Menu(14)- Section 8



Strings

STRINGS 2.5 Copyright 1991-1993, 1995 Douglas Boling   First published in PC Magazine, December 29, 1992 If this third-party file is placed on your computers search PATH, example: "C:\windows\command\STRINGS.COM", then you can use the "good old utility": The STRINGS command. Usage: STRINGS [/?][/M][/Q][/Pc][/Bn][/I][/U] [env var =] FUNCTION [Params] /M - Use master environment /Q - Suppress output to screen /Pc - Use char c instead of ',' as the parse character /Bn - Use n as the number base /I - Installs as resident code. DOS 3.3 or later required /U - Uninstalls if resident

Table of Contents

Convert numbers
   Dec. to binary

Batchfiles
   MAX.BAT      Greatest number?
   WATCH.BAT    Stopwatch
   DELIVER.BAT  Get filenames & Deliver each filename to some function(s).
   SPLIT.BAT    Splits a file into multiple smaller files.
   INFINITY.BAT The definition of BENNYLEVEL. I used both STRINGS and SED.

INPUT from, about the system
   Memory
   Environment
   Disk
   Drive
   Directory
   File
   Date & Time
   Various


INPUT from or about the system

*  Memory        

:: The amount of conventional memory....... Strings x=MEMTOTAL
:: Largest block of free conventional mem.. Strings x=MEMFREE
:: Largest block of free upper memory...... Strings x=UMBLARGE
:: Amount of extended memory............... Strings x=XMSTOTAL
:: Amount of free extended memory.......... Strings x=XMSFREE
:: Version of the extended memory driver... Strings x=XMSVER
:: Amount of expanded memory............... Strings x=EMSTOTAL
:: Amount of free expanded memory.......... Strings x=EMSFREE
:: Version of the expanded memory driver... Strings x=EMSVER

:: The offset of a series of bytes in memory
   Strings x=SCAN Segment, Starting offset, b1 [,b2]

:: A series of bytes from memory
   Strings x=PEEK Segment, Offset [, n bytes [,Word flag]]

:: Writes up to 8 bytes to memory
   Strings x=POKE Segment, Offset,b1[,b2][,b3]... [,b8]

*  Environment   

:: Bytes free in the environment........... Strings x=ENVFREE
:: Size of the environment................. Strings x=ENVSIZE
:: Address of the master environment....... Strings x=MASTERENV
:: A variable from the master environment.. Strings x=MASTERVAR Variable

*  Disk          

:: Free disk space (Mb).................... See WHAT.EXE

*  Drive         

:: Current drive........................... Strings x=FILEDRIVE nul
:: Drive of a filename..................... Strings x=FILEDRIVE filename
:: Letter of the last possible drive....... Strings x=LASTDRIVE

*  Directory     

:: Current directorys...................... Strings x=FILEDIR *
:: Directorys of a filename................ Strings x=FILEDIR filename

*  File          

:: Complete filename....................... Strings x=TRUENAME filename
:: Filename................................ Strings x=FILENAME filename
:: File extension.......................... Strings x=FILEEXT filename
:: File size (byte)........................ Strings x=FILESIZE filename
:: File size (Kb).......................... See WHAT.EXE
:: Number of lines......................... Strings x=LINESIZE filename
   REM Find/v/c "á4^z£Ï5" %0

*  Date & Time   

:: The date of a file...................... Strings x=FILEDATE Filename
:: The time of a file...................... Strings x=FILETIME Filename
:: The current date as Month dd, yyyy...... Strings x=DATE
:: The name of the month................... Strings x=MONTH [Index (1=Jan)]
::
      Strings m04=MONTH 4
      Strings mon=MONTH
      If not %mon%==%m04% Echo ** It's not April but %mon% **

:: The name of the day of the week......... Strings x=DAY   [Index (1=Sun)]
:: The current time........................ Strings x=TIME
:: The date for the ROM BIOS............... Strings x=BIOSDATE

*  Various       

:: DOS version number...................... Strings x=VER
:: Truever (DOS 5.0 or later).............. Strings x=TRUEVER
:: Windows running?........................ Strings x=INWIN
::
      If %x%==1 Echo WIN IS RUNNING (%WINdir%)
      The usual method:... If not %WINdir%'==' Echo YES. (%WINdir%)

:: Country code for the system............. Strings x=COUNTRY
:: Active codepage (DOS 3.3 or later)...... Strings x=CODEPAGE
:: Total number of files that can be open.. Strings x=FILES


 Greatest number?

    Example:   call max n1 n2

    Returns:   If %max%==0 Echo equals
               If %max%==1 Echo n1 is greater than n2
               If %max%==2 Echo n%max% is greater than n1

::  MAX.BAT
::
    SET MAX=0
    IF %1'==%2' GOTO 0
    IF %2==0 GOTO 1
    STRINGS MAX=DIV %1, %2
    IF NOT %MAX%==0 GOTO 1
    SET MAX=2
    GOTO 0
    :1
    SET MAX=1
    :0


    Here's my stopwatch (version 1.01).
    Strings.com v2.5 is used.

Note:
    if your OS is English (not Danish), then
    you MUST substitute "Klokken" with "Current".

Win9x hint:
    Press [Ctrl+Alt+Del] and close aplications such as anti virus etc.,
    would returns less values of used milli seconds.
    WATCH.BAT runs fast on a RAM drive.

--- call_it.bat:

@echo off
::   rem | choice /tn,4 (Pause between 300 and 500 mS.) <nul>nul
call watch start
call watch end

--- watch.bat: (31 lines and EXACT 1024 bytes)

@echo if not %%1!==! goto !>Klokken.bat
::@ if OS=English (not Danish), then substitute "Klokken" with "Current".
@echo. | TIME>>Klokken.bat
find /v "@" <watch.bat>>Klokken.bat
if end==%1 call mSeconds @
@if end==%1 set mSeconds=%mS%
for %%@ in (call del goto:%1) do %%@ Klokken.bat
:!
shift
strings t=find %1,.
if %t%==0 goto !
set t=
strings L=length %1
if %L%==7 set t=0
strings h=mid %t%%1,1,2
strings m=mid %t%%1,4,2
strings s=mid %t%%1,7,2
strings h=mul %h%,36
strings mS=add %h%0000,%m%000,%m%000,%m%000,%m%000,%m%000,%m%000,%s%00,%2
echo set mS=%mS%>mSeconds.bat
::@ for %%v in (%1'%2: %mS% .) do echo %%v
for %%v in (h m s mS L t) do set %%v=
:end @
for %%@ in (call del) do %%@ mSeconds.bat
@set SelfTime=09
@strings sub %mS%,%mSeconds%,%SelfTime% | find "underflow">nul
@if not errorlevel 1 strings SelfTime=sub %SelfTime%,01
@strings mS=sub %mS%, %mSeconds%, %SelfTime%
for %%@ in (echo:[%mS%] echo. pause cls) do %%@
for %%@ in (SelfTime mSeconds mS cmdline) do set %%@=
:start @

--- WATCH.BAT: (32 lines and 921 bytes).
    This version runs faster. Whether it's on a RAM drive or a normal HD,
    total about 5 milli seconds. Line number 25: "timeEND -timeSTART -4",
    (5 -4 = 1 milli second) so, whether it's on a RAM drive or a
    normal HD, it returns about 1/100 second.

    To get rid of the SHIFT command, I used a little tricks:
    The TIME command returns three words in English but only
    two words in Danish: "Current time is" and "Klokken er".
    The reverce order %4 %3 %2 (see below), did this tricks.

GOTO %1!
:END!
KLOKKEN
:START!!
SET U=%3.%2
ECHO IF NOT %%1!==! %0 %1! %%4 %%3 %%2>KLOKKEN.BAT
ECHO. | TIME>>KLOKKEN.BAT
Klokken
:start!!!
echo ! | choice /c%u%!> nul
for %%! in (0 00) do if not errorlevel +%%! set t=%%!
strings h=mid %t%%u%,2,2
strings m=mid %t%%u%,5,2
strings s=mid %t%%u%,8,2
strings u=mid %t%%u%,11,2
strings h=mul %h%,36
strings u=add %h%0000,%m%000,%m%000,%m%000,%m%000,%m%000,%m%000,%s%00,%u%
echo ! | choice /c'''%3!> nul
for %%! in (0 00) do if not errorlevel +%%! set t=%%!
strings h=mid %t%%3,2,2
strings m=mid %t%%3,5,2
strings s=mid %t%%3,8,2
strings h=mul %h%,36
strings t=add %h%0000,%m%000,%m%000,%m%000,%m%000,%m%000,%m%000,%s%00,%2
strings u=sub %t%,%u%,4
echo [%u%]
for %%! in (u L t h m s cmdline) do set %%!=
for %%! in (del pause cls goto:!) do %%! Klokken.bat
:START!
echo if not %%1!==! %0 %1! %%4 %%3 %%2> Klokken.bat
ECHO. | TIME>>KLOKKEN.BAT
:!


 Problem:

               A number such as 255.000.000.000.000.000 maybe
               a problem for DOS? But not for a simple batch-
               program.

               I used the following program to solve the math
               problem, which is the solution for the synonym
               named bennylevel [described by William Allen].

infinity
     SUM  ((10^(i-1)) (Xi-48))  =  256n +e
     i=1


 Solution:

    @echo off
    for %%v in (//) do echo%%v
    strings v=char 32,32,32,32,32,32,32,32,32,32
    strings e= ask ÿ ?:    %v%  IF ERRORLEVEL=
    echo "%e%" | find "," >nul
    if not errorlevel 1 goto e
    echo "%e%" | find "|" >nul
    if not errorlevel 1 goto e
    echo "%e%" | find ">" >nul
    if not errorlevel 1 goto e
    echo "%e%" | find "<" >nul
    if not errorlevel 1 goto e
    echo "%e%" | find ";" >nul
    if not errorlevel 1 goto e

    :: substitutes ASCII char. 21dec(15hex) with 59dec(3Bhex)
    echo:%e%| sed "s/\x15/\x3B/g;s/^/set e=/" >%temp%\A21.bat
    call %temp%\A21.bat

    if "%e%"=="" for %%v in (echo set:e) do %%v= %v%%v%%v% HA
    strings e=parse %e%, 1,
    strings e=right %e%, 8,
    strings v=length %e%
    strings e=val %e%

    echo: %e%|find " 61 " >nul
    if not errorlevel 1 goto e

    echo: %e%|sed "s/^/set e=/;s/\<59\>/21/g" >%temp%\A21.bat
    for %%v in (call del) do %%v %temp%\A21.bat

    set i=1
    strings /p\ s= parse 208,240,48,176,176,176,176,176\%v%\,
 :repeat
    strings /p\ ai=parse 1,10,100,232,16,160,64,128,0,0\%i%\,
    strings /p\ xi=parse %e% \%v%
                strings char %xi%
    strings /p* ax=mul %xi% *%ai%
    strings /p+ s = add %s% +%ax%
    strings /p+ i = add %i% +1
    strings /p- v = sub %v% -1 | find "STRINGS 2.5 Copyright"
                                 if not errorlevel xxA goto e
    if not %v%==0 goto: repeat
    strings /p/ v=div %s% /256
    strings /p* v=mul %v% *256
    strings /p- s=sub %s% -%v%
    echo.  It's the same as: IF ERRORLEVEL=%s%
    for %%v in (e v s i ai xi ax ) do set %%v=
    for %%v in (echo. echo. pause cls goto:eof) do %%v
 :e msg
    for %%v in (echo.ÿillegalÿcharacter. pause cls %0) do %%v
 :EOF

 :: Example of purpose: [Thee may click on this link]


 Strings.com
    Download "strings.zip" (v2.5)


-Top- | -Menu(14)- Section 8