Computing.Net > Forums > Windows XP > DOS code to display percent complet

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

DOS code to display percent complet

Reply to Message Icon

Name: Soskip
Date: August 21, 2008 at 16:46:48 Pacific
OS: Windows XP
CPU/Ram: 128
Product: Intel
Comment:

Greetings All!

The following is some DOS code I put together. It allows for a percentage of completion to be displayed of a DOS program. It was created for Admins to monitor progress of DOS programs which run on the network. Often we (Admins) have to run DOS programs and we don't know how long until completion. Now we can! (With limitations...)

The code scans an input file and counts the number of lines to process. It then computes the fractional and displays the result. DOS doesn't like displaying real numbers (12.234 etc) so I had to work the code to simulate a real number output.

Keys: counter(s) in DOS
Keys: real number(s) in DOS

Start Code:
-------------

REM This program will display the percent of completion
REM in pinging all computers on the domain.
REM
REM Keywords: counter,counters,loop,percent,dos,windows,decimal,complete,completion
REM
REM Written by: Pete Soski (soskip@yahoo.com)
REM Assisted by: Daniel Westphal
REM Creation Date: 21 Aug 2008
REM
cls
@ECHO OFF
net view > clients.txt
setlocal
set Total=0
set Current=0
set PC=0
set MC=0
set Long=0
set Dec=0
set CName=0
set NName=0

FOR /F "skip=3" %%i IN (clients.txt) DO (set /A Total+=1)
FOR /F "skip=3" %%i IN (clients.txt) DO (call :MAIN %%i)
goto END

:END
Echo.
Echo End of program
Echo.
del clients.txt
set Total=0
set Current=0
set PC=0
set MC=0
set Long=0
set Dec=0
set CName=0
set NName=0
endlocal
exit

:MAIN
cls
Echo.
Echo.
set /A Current+=1
set /A PC = ((%Current%*100)/%Total%)
set /A MC = ((%Current%*10000)/%Total%)
set Dec=%MC:~-2%
set Long=%PC%.%dec%
Echo.
Echo Percent Complete: %PC%
Echo Percent Complete, Long form: %Long%
Echo.
set cname=%1%
set nname=%cname:~2%


ping %nname%


if %PC%==100 (pause)

---------------
end of code

Good Luck!
~Pete



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: DOS code to display percent complet

Getting NT to read a DOS code. www.computing.net/answers/windows-xp/getting-nt-to-read-a-dos-code/77816.html

Desktop Shortcut to Display www.computing.net/answers/windows-xp/desktop-shortcut-to-display/163076.html

IE fails to display in new window www.computing.net/answers/windows-xp/ie-fails-to-display-in-new-window/34035.html