Loading ...
Sorry, an error occurred while loading the content.

progress bar

Expand Messages
  • Aristos Vasiliou
    Hello, Is there a way to add some kind of progress indicator in a batch file? Maybe stars, or something going like this |/- |/- You know something like a
    Message 1 of 6 , Aug 12, 2009
    • 0 Attachment
      Hello,

      Is there a way to add some kind of progress indicator in a batch file? Maybe stars, or something going like this \|/-\|/- You know something like a spinning line.

      It doesn't have to be exact, just something showing the user that things are moving. I want to use this while installing programs using a batch file.

      Thanks



      [Non-text portions of this message have been removed]
    • procyon50@gmail.com
      On Wed, 12 Aug 2009 17:41:07 +0300, Aristos Vasiliou ... From: Herbert Kleebauer echo a E: filename.___ echo @echo off _.bat echo :loop _.bat echo cls
      Message 2 of 6 , Aug 12, 2009
      • 0 Attachment
        On Wed, 12 Aug 2009 17:41:07 +0300, "Aristos Vasiliou"
        <aristos@...> wrote:

        >Is there a way to add some kind of progress indicator in a batch file? Maybe stars, or something going like this \|/-\|/- You know something like a spinning line.
        >
        >It doesn't have to be exact, just something showing the user that things are moving. I want to use this while installing programs using a batch file.
        >
        >Thanks




        From: Herbert Kleebauer

        echo a>E:\filename.___
        echo @echo off>_.bat
        echo :loop>>_.bat
        echo cls >>_.bat
        echo for %%%%i in (E:\filename.ext) do echo %%%%~zi>>_.bat
        echo ping -n 2 127.0.0.1 ^>nul>>_.bat
        echo if exist E:\filename.___ goto :loop>>_.bat
        echo exit>>_.bat
        start _.bat
        copy "D:\filename.ext" "E:\filename.ext"
        del E:\filename.___
        ping -n 3 127.0.0.1 >nul
        del _.bat





        :: BEGIN FILE ::::::::::::::::::::::::::::::::::::::::::::::::::::
        :: ProgBar.cmd
        :: Frank P. Westlake, 2009-07-23
        :: Demonstrates a progress bar.
        :: Set variable 'size' with the number of times a loop will
        :: be accomplished.
        @ECHO OFF
        SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
        Set /A size=1234, progress=0, item=0, last=0
        Echo.Processing %size% items . . .
        :: Save current code page for restoration at completion.
        For /F "tokens=2 delims=:" %%a in ('CHCP') Do Set "CP=%%a"
        :: Using code page 437 for the character 'Û' in the progress bar.
        CHCP 437 >NUL:
        :: Progress bar caption.
        Echo. 10 20 30 40 50 60 70 80 90 100%%
        :: A 7-bit ASCII progress indicator.
        ::Set "indicator=___"
        :: An 8-bit progress indicator.
        Set "indicator=ÛÛÛ"
        :: A demonstration loop.
        For /L %%i in (0 1 %size%) Do (
        Set /A item+=1,progress=item*10/%size%
        If !last! NEQ !progress! (
        Set /P "=!indicator!"<NUL:
        Set /A last=progress
        )
        Call :DoNothing
        )
        :: Terminate the progress bar.
        Echo.%indicator:~0,2%
        :: Say bye now.
        Echo.Bye.
        :: Restore the computer operator's code page.
        CHCP %CP% >NUL:
        :: Goto :EOF.
        Goto :EOF


        :DoNothing
        ::Not doing anything yet . . .
        :: Goto :EOF again.
        Goto :EOF
        :: END OF FILE :::::::::::::::::::::::::::::::::::::::::::::::::::




        :: BEGIN FILE ::::::::::::::::::::::::::::::::::::::::::::::::::::
        :: ProgBar.cmd
        :: Frank P. Westlake, 2009-07-23
        :: Demonstrates a progress bar.
        :: Set variable 'size' with the number of times a loop will
        :: be accomplished.
        @ECHO OFF
        SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
        Set /A size=1234, progress=0, item=0, last=0
        Echo.Processing %size% items . . .
        :: Save current code page for restoration at completion.
        For /F "tokens=2 delims=:" %%a in ('CHCP') Do Set "CP=%%a"
        :: Using code page 437 for the character 'Û' in the progress bar.
        CHCP 437 >NUL:
        :: Progress bar caption.
        Echo. 10 20 30 40 50 60 70 80 90 100%%
        :: 7-bit ASCII progress indicator.
        ::Set "indicator=___"
        :: 8-bit progress indicator (Û=DBh, the inverted space character).
        ::Set "indicator=ÛÛÛ"
        Set "indicator=±±±"
        :: A demonstration loop.
        For /L %%i in (0 1 %size%) Do (
        Set /A item+=1,progress=item*10/%size%
        If !last! NEQ !progress! (
        Set /P "=!indicator!"<NUL:
        Set /A last=progress
        )
        Call :DoNothing
        )
        :: Terminate the progress bar.
        Echo.%indicator:~0,2%
        :: Say bye now.
        Echo.Bye.
        :: Restore the computer operator's code page.
        CHCP %CP% >NUL:
        :: Goto :EOF.
        Goto :EOF


        :DoNothing
        ::Not doing anything yet . . .
        :: Goto :EOF again.
        Goto :EOF
        :: END OF FILE :::::::::::::::::::::::::::::::::::::::::::::::::::




        and a couple of animations in batch files:





        ::Demo-WaitMsg.cmd:::::::::::::::::::::::::::::::::::::::::::::::::::
        @echo off
        Call :WaitMsg ....Whatever you want to display....
        pause
        goto :EOF
        ::Sub WaitMsg::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        :WaitMsg messages containing no qoutes
        setlocal&set "LoopCnt=3000"&set "cnt=0"&set "step=1"&set text=%*
        :WaitMLoop
        cls&echo.&set /A cnt+=step
        call set txt=%%text:~-%cnt%%%
        for %%a in (/ - \ ^| / - \ ^|) do (echo ^%%a%txt%
        for /L %%b in (1,1,%LoopCnt%) do set dummy=%%b
        cls & echo.)
        if %cnt%. EQU 0. goto :eof
        if "%txt%" NEQ "%text%" goto :WaitMLoop
        echo %text%
        ping -n 3 127.0.0.1 >nul
        cls&echo.&set step=-1
        goto :WaitMLoop
        ::Demo-WaitMsg.cmd:::::::::::::::::::::::::::::::::::::::::::::::::::
        :: Matthias Tacke




        @echo off
        cls & echo.
        set "text=....Waiting for the network to startup...."

        :: calculate the length of the text string
        for /f "tokens=1* delims=:" %%a in (
        '^(for %%i in ^("%text%" .^) do @echo %%i^) ^| findstr /o .^| ^
        findstr /v /b 0') do set /a v=%%~a-5

        for /L %%a in (1,1,%v%) do call set "txt=%%text:~0,%%a%%"&call :show out
        echo %text%
        ping -n 3 127.0.0.1 >nul
        cls & echo.
        for /L %%a in (2,1,%v%) do call set "txt=%%text:~%%a%%"&call :show in

        echo Please wait...
        Rem Startup routine goes here
        pause
        goto :EOF

        :show
        for %%a in (/ - \ ^| / - \ ^|) do (
        if %1==out echo %txt%^%%a
        if %1==in echo ^%%a%txt%
        for /L %%b in (1,1,1000) do set dummy=%%b
        cls & echo.
        )







        @echo off
        set text=....Waiting for the network to startup....
        for /L %%a in (1,1,42) do call set txt=%%text:~0,%%a%%&call :show
        Title %text%

        echo Please wait...
        Rem Startup routine goes here
        pause
        goto :EOF

        :show
        for %%a in (/ - \ ^| / - \ ^|) do (
        Title %txt%^%%a
        for /L %%b in (1,1,1000) do set dummy=%%b
        cls & echo.
        )
      • Theodorik OBroin
        Hi, Cheers for getting me to look at this again. I find the easiest way is to update the title - that way you don t have to do a CLS all the time. The reason
        Message 3 of 6 , Aug 12, 2009
        • 0 Attachment
          Hi,

          Cheers for getting me to look at this again.

          I find the easiest way is to update the title - that way you don't have to
          do a CLS all the time.

          The reason for the two lines of ping -n, is that it's quicker for ping to
          do a double ping of a second each, versus a single ping of two seconds.
          Try it out for yourself.

          Let me know how you get on :o)

          Here's my version thus far:

          :: begin spin.cmd
          @echo off
          setlocal

          set COUNT=0
          set MAXCOUNT=10
          set SECONDS=1

          :LOOP
          title "\"
          call :WAIT
          title "|"
          call :WAIT
          title "/"
          call :WAIT
          title "-"
          if /i "%COUNT%" equ "%MAXCOUNT%" goto :EXIT
          set /a count+=1
          echo %COUNT%
          goto :LOOP

          :WAIT
          ping -n %SECONDS% 127.0.0.1 > nul
          ping -n %SECONDS% 127.0.0.1 > nul
          goto :EOF

          :EXIT
          title FIN!
          endlocal
          :: end spin.cmd




          2009/8/12 Aristos Vasiliou <aristos@...>

          >
          >
          > Hello,
          >
          > Is there a way to add some kind of progress indicator in a batch file?
          > Maybe stars, or something going like this \|/-\|/- You know something like a
          > spinning line.
          >
          > It doesn't have to be exact, just something showing the user that things
          > are moving. I want to use this while installing programs using a batch file.
          >
          > Thanks
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >


          [Non-text portions of this message have been removed]
        • Josh Fitzgerald
          Check out this post on stack overflow: How to code a spinner for waiting processes in a batch file?
          Message 4 of 6 , Aug 12, 2009
          • 0 Attachment
            Check out this post on stack overflow:

            How to code a spinner for waiting processes in a batch file?
            <http://stackoverflow.com/questions/368041/how-to-code-a-spinner-for-wai\
            ting-processes-in-a-batch-file/>




            --- In batchworld@yahoogroups.com, "Aristos Vasiliou" <aristos@...>
            wrote:
            >
            > Hello,
            >
            > Is there a way to add some kind of progress indicator in a batch file?
            Maybe stars, or something going like this \|/-\|/- You know something
            like a spinning line.
            >
            > It doesn't have to be exact, just something showing the user that
            things are moving. I want to use this while installing programs using a
            batch file.
            >
            > Thanks
            >
            >
            >
            > [Non-text portions of this message have been removed]
            >




            [Non-text portions of this message have been removed]
          • Aristos Vasiliou
            Hi, Thanks for your reply. This is my batch file so far. @ECHO off title Installing Software ECHO. ECHO Instaling Net Framework dotnetfx35.exe /qb /norestart
            Message 5 of 6 , Aug 12, 2009
            • 0 Attachment
              Hi,



              Thanks for your reply. This is my batch file so far.



              @ECHO off

              title Installing Software

              ECHO.

              ECHO Instaling Net Framework

              dotnetfx35.exe /qb /norestart

              ECHO.

              ECHO Instaling TextPad

              TextPad 5.msi /qb

              ECHO.

              ECHO All Software Installed

              EXIT



              How do I integrate your batch file with mine?



              Thanks



              From: batchworld@yahoogroups.com [mailto:batchworld@yahoogroups.com] On
              Behalf Of Theodorik OBroin
              Sent: Wednesday, August 12, 2009 7:46 PM
              To: batchworld@yahoogroups.com
              Subject: Re: [BATCH WORLD] progress bar





              Hi,

              Cheers for getting me to look at this again.

              I find the easiest way is to update the title - that way you don't have
              to
              do a CLS all the time.

              The reason for the two lines of ping -n, is that it's quicker for ping
              to
              do a double ping of a second each, versus a single ping of two seconds.
              Try it out for yourself.

              Let me know how you get on :o)

              Here's my version thus far:

              :: begin spin.cmd
              @echo off
              setlocal

              set COUNT=0
              set MAXCOUNT=10
              set SECONDS=1

              :LOOP
              title "\"
              call :WAIT
              title "|"
              call :WAIT
              title "/"
              call :WAIT
              title "-"
              if /i "%COUNT%" equ "%MAXCOUNT%" goto :EXIT
              set /a count+=1
              echo %COUNT%
              goto :LOOP

              :WAIT
              ping -n %SECONDS% 127.0.0.1 > nul
              ping -n %SECONDS% 127.0.0.1 > nul
              goto :EOF

              :EXIT
              title FIN!
              endlocal
              :: end spin.cmd

              2009/8/12 Aristos Vasiliou <aristos@...
              <mailto:aristos%40aristos.net> >

              >
              >
              > Hello,
              >
              > Is there a way to add some kind of progress indicator in a batch file?
              > Maybe stars, or something going like this \|/-\|/- You know something
              like a
              > spinning line.
              >
              > It doesn't have to be exact, just something showing the user that
              things
              > are moving. I want to use this while installing programs using a batch
              file.
              >
              > Thanks
              >
              > [Non-text portions of this message have been removed]
              >
              >
              >

              [Non-text portions of this message have been removed]





              __________ Information from ESET NOD32 Antivirus, version of virus
              signature database 4329 (20090812) __________

              The message was checked by ESET NOD32 Antivirus.

              http://www.eset.com



              __________ Information from ESET NOD32 Antivirus, version of virus
              signature database 4330 (20090812) __________



              The message was checked by ESET NOD32 Antivirus.



              http://www.eset.com



              [Non-text portions of this message have been removed]
            • Theodorik OBroin
              Hi, Cheers to Josh for his link. I ve taken the batch file listed there, and together with your script, have created a different script. I dunno about you, but
              Message 6 of 6 , Aug 12, 2009
              • 0 Attachment
                Hi,

                Cheers to Josh for his link.

                I've taken the batch file listed there, and together with your script,
                have created a different script.
                I dunno about you, but when I ran the batch file listed in Josh's link, it
                didn't do the backspace for me.

                I chose this, as I found the flaw in my program. It would only rotate
                when it was not installing something, which wasn't what you wanted.
                This program does what I would have done, except it works.

                The only prerequisite is that you have the .net framework and textpad
                installers in the same directory as the batch file.

                I have only tested it with the "notepad", and what I see is that while
                notepad is open, the spinner works. :o)
                Just close each notepad to see the program advance.

                :: begin Net-Textpad-Installer.cmd
                @echo off

                :: Localise environment.
                setlocal
                cls

                :: Specify directories. Your current working directory is used
                :: to create temporary files tmp_*.*
                set wkdir=%~dp0%
                :: For testing, uncomment the next line to show what the above line does
                :: echo %wkdir%
                set wkdir=%wkdir:~0,-1%
                :: For testing, uncomment the next line to show what the above line does
                :: echo %wkdir%

                :: First pass, Installing .Net Framework
                :: Use Last to find out if this is the last program to install
                set Last=0
                del "%wkdir%\tmp_*.*" 2>nul
                echo >>"%wkdir%\tmp_payload.cmd" dotnetfx35.exe /qb /norestart
                :: For testing, comment out the above line, and uncomment the line below
                :: echo >>"%wkdir%\tmp_payload.cmd" notepad
                echo >>"%wkdir%\tmp_payload.cmd" del "%wkdir%\tmp_payload.flg"
                :: On the next line, I removed the numerical value at the end with the app
                being installed, so as to inform the user
                call :monitor "%wkdir%\tmp_payload.cmd" "%wkdir%\tmp_payload.flg" .Net
                Framework

                :: Second pass, Installing Textpad
                :: This is the last program to be installed, so FIN! will appear in the
                title
                set Last=1
                del "%wkdir%\tmp_*.*" 2>nul:
                echo >>"%wkdir%\tmp_payload.cmd" TextPad 5.msi /qb
                :: For testing, comment out the above line, and uncomment the line below
                :: echo >>"%wkdir%\tmp_payload.cmd" notepad
                echo >>"%wkdir%\tmp_payload.cmd" del "%wkdir%\tmp_payload.flg"
                :: On the next line, I removed the numerical value at the end with the app
                being installed, so as to inform the user
                call :monitor "%wkdir%\tmp_payload.cmd" "%wkdir%\tmp_payload.flg" Textpad

                goto :final

                :monitor
                :: Create flag file and start the payload minimized.
                echo >>%2 dummy
                start /min cmd.exe /c "%1"

                :: Start monitoring.
                :: i is the indicator (0=|,1=/,2=-,3=\).
                set i=0

                :: Loop here awaiting completion.
                :loop
                :: Wait one second.
                :: For a fast spinner, use -n 1
                :: For a slow spinner, use -n 2
                ping 127.0.0.1 -n 1 >nul

                :: Update counters and output progress indicator.
                set /a "i = i + 1"
                if %i% equ 4 set i=0
                if %i% equ 0 <nul (title Installing %3 %4 "|")
                if %i% equ 1 <nul (title Installing %3 %4 "/")
                if %i% equ 2 <nul (title Installing %3 %4 "-")
                if %i% equ 3 <nul (title Installing %3 %4 "\")

                :: End conditions, wait until application finished installing.
                if not exist %2 (
                echo. %3 %4 Installed.
                if %Last% equ 1 (
                title FIN!
                )
                del "%wkdir%\tmp_*.*" 2>nul
                goto :final
                )
                goto :loop
                :final
                endlocal

                :: end Net-Textpad-Installer.cmd





                2009/8/12 Aristos Vasiliou <aristos@...>

                >
                >
                > Hi,
                >
                > Thanks for your reply. This is my batch file so far.
                >
                > @ECHO off
                >
                > title Installing Software
                >
                > ECHO.
                >
                > ECHO Instaling Net Framework
                >
                > dotnetfx35.exe /qb /norestart
                >
                > ECHO.
                >
                > ECHO Instaling TextPad
                >
                > TextPad 5.msi /qb
                >
                > ECHO.
                >
                > ECHO All Software Installed
                >
                > EXIT
                >
                > How do I integrate your batch file with mine?
                >
                > Thanks
                >
                > From: batchworld@yahoogroups.com <batchworld%40yahoogroups.com> [mailto:
                > batchworld@yahoogroups.com <batchworld%40yahoogroups.com>] On
                > Behalf Of Theodorik OBroin
                > Sent: Wednesday, August 12, 2009 7:46 PM
                > To: batchworld@yahoogroups.com <batchworld%40yahoogroups.com>
                > Subject: Re: [BATCH WORLD] progress bar
                >
                >
                > Hi,
                >
                > Cheers for getting me to look at this again.
                >
                > I find the easiest way is to update the title - that way you don't have
                > to
                > do a CLS all the time.
                >
                > The reason for the two lines of ping -n, is that it's quicker for ping
                > to
                > do a double ping of a second each, versus a single ping of two seconds.
                > Try it out for yourself.
                >
                > Let me know how you get on :o)
                >
                > Here's my version thus far:
                >
                > :: begin spin.cmd
                > @echo off
                > setlocal
                >
                > set COUNT=0
                > set MAXCOUNT=10
                > set SECONDS=1
                >
                > :LOOP
                > title "\"
                > call :WAIT
                > title "|"
                > call :WAIT
                > title "/"
                > call :WAIT
                > title "-"
                > if /i "%COUNT%" equ "%MAXCOUNT%" goto :EXIT
                > set /a count+=1
                > echo %COUNT%
                > goto :LOOP
                >
                > :WAIT
                > ping -n %SECONDS% 127.0.0.1 > nul
                > ping -n %SECONDS% 127.0.0.1 > nul
                > goto :EOF
                >
                > :EXIT
                > title FIN!
                > endlocal
                > :: end spin.cmd
                >
                > 2009/8/12 Aristos Vasiliou <aristos@... <aristos%40aristos.net>
                > <mailto:aristos%40aristos.net <aristos%2540aristos.net>> >
                >
                > >
                > >
                > > Hello,
                > >
                > > Is there a way to add some kind of progress indicator in a batch file?
                > > Maybe stars, or something going like this \|/-\|/- You know something
                > like a
                > > spinning line.
                > >
                > > It doesn't have to be exact, just something showing the user that
                > things
                > > are moving. I want to use this while installing programs using a batch
                > file.
                > >
                > > Thanks
                > >
                > > [Non-text portions of this message have been removed]
                > >
                > >
                > >
                >
                > [Non-text portions of this message have been removed]
                >
                > __________ Information from ESET NOD32 Antivirus, version of virus
                > signature database 4329 (20090812) __________
                >
                > The message was checked by ESET NOD32 Antivirus.
                >
                > http://www.eset.com
                >
                > __________ Information from ESET NOD32 Antivirus, version of virus
                > signature database 4330 (20090812) __________
                >
                > The message was checked by ESET NOD32 Antivirus.
                >
                > http://www.eset.com
                >
                > [Non-text portions of this message have been removed]
                >
                >
                >


                [Non-text portions of this message have been removed]
              Your message has been successfully submitted and would be delivered to recipients shortly.