Announcement

Collapse
No announcement yet.

Batch Progress Bar

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Batch Progress Bar

    Hi,

    I'm trying to incorporate the progress bar scripting that I've found at other posting thread: 29131

    Sample:

    Code:
    ::# install MSI 
     
    @echo off
    setLocal
    :: local variable %percent% is reserved!
     
    :: job launch
    Set "sProc=msiexec.exe"
    start ""/Min "%windir%\system32\%sProc%" /I logmein.msi /quiet USERPASSWORD=pcpassword USERVERIFYPWD=pcpassword [email protected]
    call :DisplayProgressBar %sProc% 3
     
    :End of Batch
      
    goto:EOF --------------------
    :DisplayProgressBar SUBROUTINE
    If not defined percent (
       setlocal
       echo.&echo/    * DO NOT CLOSE THIS WINDOW *&echo.
       Set "wait=ping 127.0.0.1 -n"
       Set "monitoring=%1"
       Set /a n = %2
       set /a percent = 0
       <nul (Set /P j=Installing)
     ) Else ( <nul (Set /P j=.) )
    >nul 2>&1 (
       title %percent% %%  Completed
       If %n% NEQ 1 (
          For /f %%# in (
            'tasklist.exe ^| find /i /c "%monitoring%"'
          ) Do if NOT %%# GTR 0 Set /a n = 1
       )
    )
    >nul (%wait% %n%) & set /a percent = percent + 1
    If %percent% LEQ 100 (
       call:DisplayProgressBar
     ) Else (
     title Done
     <nul (Set /P j=) & echo/100%% Completed
     >nul (%wait% 2)
     EndLocal
    )
    goto:EOF --------------------
    This portion is currently working OK, however, I'm having some problem to execute more than 1 intallation tasks, assuming I've another installation task which will be run after the first task is completed.

    Whenever, the first installation task is completed, the progress bar window closes by itself.

    Could you advise how to launch another installation task using the same progress bar window?

    Appreciate for your help.

    Thank you.



    - James
    Last edited by Rems; 13th December 2012, 09:26.

  • #2
    Re: Batch Progress Bar

    What happens if you add another installer and call the progress subroutine again?


    Code:
    ::# install MSI 
     
    @echo off
    setLocal
    :: local variable %percent% is reserved!
     
    :: job launch
    Set "sProc=msiexec.exe"
    start ""/Min "%windir%\system32\%sProc%" /I logmein.msi /quiet USERPASSWORD=pcpassword USERVERIFYPWD=pcpassword [email protected]
    call :DisplayProgressBar %sProc% 3
    
    ::Next Installer...
    start ""/Min "%windir%\system32\%sProc%" /I otherApp.msi /quiet /moreParamsEtc...
    call :DisplayProgressBar %sProc% 3
    
    
     
    :End of Batch
      
    goto:EOF --------------------
    :DisplayProgressBar SUBROUTINE
    If not defined percent (
       setlocal
       echo.&echo/    * DO NOT CLOSE THIS WINDOW *&echo.
       Set "wait=ping 127.0.0.1 -n"
       Set "monitoring=%1"
       Set /a n = %2
       set /a percent = 0
       <nul (Set /P j=Installing)
     ) Else ( <nul (Set /P j=.) )
    >nul 2>&1 (
       title %percent% %%  Completed
       If %n% NEQ 1 (
          For /f %%# in (
            'tasklist.exe ^| find /i /c "%monitoring%"'
          ) Do if NOT %%# GTR 0 Set /a n = 1
       )
    )
    >nul (%wait% %n%) & set /a percent = percent + 1
    If %percent% LEQ 100 (
       call:DisplayProgressBar
     ) Else (
     title Done
     <nul (Set /P j=) & echo/100%% Completed
     >nul (%wait% 2)
     EndLocal
    )
    goto:EOF --------------------
    Regards,
    Jeremy

    Network Consultant/Engineer
    Baltimore - Washington area and beyond
    www.gma-cpa.com

    Comment


    • #3
      Re: Batch Progress Bar

      Hi Jeremy,

      Thanks for your advise.

      I've tried your method and it's working OK.

      Code:
      @echo off
      setLocal
       
      Set "sProc=msiexec.exe"
      start ""/Min "%windir%\system32\%sProc%" /I logmein.msi /quiet USERPASSWORD=pcpassword USERVERIFYPWD=pcpassword [email protected]
      call :DisplayProgressBar %sProc% 3
       
      ::Next Installer...
      Set "sProc2=install.exe"
      start ""/Min "%windir%\system32\%sProc2%" /I otherApp.msi /quiet /moreParamsEtc...
      call :DisplayProgressBar %sProc2% 3
      :End of Batch
      However, when I tried to use if statement to ensure the installation file exist before executing it, it's only able to execute the first installation task.

      Once the first installation is completed, again, the window closes by itself without running the second one.

      Sample scripts:

      Code:
      set sProc=msiexec.exe
      set chk01=start ""/Min "%windir%\system32\%sProc%"
       
      if EXIST %chk01% (
      start ""/Min %chk01% /I logmein.msi /quiet
      call :DisplayProgressBar %sProc% 3
      ) ELSE (
      echo "FILE NOT FOUND!"
      pause
      )
       
      set sProc2=install.exe
      set chk02=start ""/Min "%windir%\system32\%sProc2%"
       
      if EXIST %chk02% (
      start ""/Min %chk02% /I logmein.msi /quiet
      call :DisplayProgressBar %sProc2% 3
      ) ELSE (
      echo "FILE NOT FOUND!"
      pause
      )
       
      :End of Batch
      I'm having some problem to figure it out what went wrong.

      Could you advise?

      Thanks.



      - James
      Last edited by james007; 13th December 2012, 14:30. Reason: Update comment

      Comment


      • #4
        Re: Batch Progress Bar

        Originally posted by james007 View Post
        However, when I tried to use if statement to ensure the installation file exist before executing it, it's only able to execute the first installation task.

        Once the first installation is completed, again, the window closes by itself without running the second one.

        Sample scripts:
        Code:
        set sProc=msiexec.exe
        set chk01=start ""/Min "%windir%\system32\%sProc%"
         
        if EXIST %chk01% (
        start ""/Min %chk01% /I logmein.msi /quiet
        call :DisplayProgressBar %sProc% 3
        ) ELSE (
        echo "FILE NOT FOUND!"
        pause
        )
        
        set sProc2=install.exe
        set chk02=start ""/Min "%windir%\system32\%sProc2%"
         
        if EXIST %chk02% (
        start ""/Min %chk02% /I logmein.msi /quiet
        call :DisplayProgressBar %sProc2% 3
        ) ELSE (
        echo "FILE NOT FOUND!"
        pause
        )
         
        :End of Batch
        I'm having some problem to figure it out what went wrong.

        Could you advise?

        Thanks.
        - James
        The value of %chk01% is: start ""/Min "%windir%\system32\%sProc%"
        WHere "start ""/min" is not a file system object and therefore the IF EXIST statement will always return "false",
        Code:
        If EXIST start ""/Min "%windir%\system32\%sProc%" (
        Additionally, if you exapand the line:
        start ""/Min %chk01% /I logmein.msi /quiet
        it will show:
        start ""/Min start ""/Min "%windir%\system32\msiexec.exe" /I logmein.msi /quiet
        the start ""/min is doubled.

        You can try something like,
        Code:
        :: :: :: ::
        
        set sProc=msiexec.exe
        set sProcFile=%windir%\system32\%sProc%
        
        set installmsi=start ""/Min "%sProcFile%" /I logmein.msi
        
        if EXIST %sProcFile% (
           %installmsi% /quiet
           call :DisplayProgressBar %sProc% 3
          ) ELSE (
           echo "FILE NOT FOUND!"
           pause
          )
        
        :: :: :: ::
        
        set sProc=install.exe
        set sProcFile=%windir%\system32\%sProc%
        
        set installmsi=start ""/Min "%sProcFile%" /I logmein.msi
         
        if EXIST %sProcFile% (
           %installmsi% /quiet
           call :DisplayProgressBar %sProc% 3
          ) ELSE (
           echo "FILE NOT FOUND!"
           pause
          )
        
        :: :: :: ::
        
        :End of Batch
        
        :: subroutines....
        Last edited by Rems; 13th December 2012, 20:31.

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment


        • #5
          Re: Batch Progress Bar

          Hi Rems,

          Got it. It's working OK now.

          Thanks for your help


          - James

          Comment

          Working...
          X