Jump to content

Count down with Progress bar


Recommended Posts

I am currently working on installing an App via GPO scripting and wanted to have a progress bar so people would know that something was being installed and would have an indicator that something was going on so that they would not turn off/reboot their pc's which has happened. I came up with the following code and was wondering if someone might have a better way of doing this and if it is possible to display Minutes:Seconds instead of just minutes.

Thanks.

;Hide the Tool Tray icon (will still display for 750 milliseconds)
AutoItSetOption("TrayIconHide", 1);1 = Hide Icon
;Turn on progress display.
ProgressOn("Installing Everdream", "This is a one time process that will take about 5 minutes.")
For $m = 5 to 0 step -1
   For $i = 100 to 0 step -1
      ProgressSet( $i, $m & " minutes until install is completed." & @LF & @LF & "Please be patient and do not reboot your PC")
      sleep(592);close to making 100 to 0  = 60 seconds when counting down.
   Next
Next
ProgressSet(0 , "Done", "Finished Install")
sleep(2000)
ProgressOff()
Link to comment
Share on other sites

Thanks,

I just wanted to check and see if there was a better/cleaner way of doing it.

Will see about adding less than 1 min in.

BTW, is there any way to expand the Progress window? I.e. to allow for more text above the progress indicator? Or to change from bold to normal text?

Thanks again.

Edited by mbouchard
Link to comment
Share on other sites

i do not believe you can change that text... but

your upper text does not fit into the box... its too long

and.. as an idea... because 5 minutes is a long time to wait

I would consider putting the window in the upper left corner/area so the user can see the install (everything is always in the middle of the screen) and if the user does not see any of the install... you may wish to put up screens every-so-often that promotes the product-uses-????

just an idea... Hope it helps

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I made a similar script which automatically shuts down computers at 11pm every night. It counts down in minutes and shows the seconds as well. Be sure to comment out the "Shutdown" function before running it, or else kill the process before it finishes its timeout.

Dim $i, $n, $x, $min, $sec, $time

Check()

Func Check()

; While 1

;  If @Hour = 23 And @Min <= 9 Then Turnoff()

;  Sleep(180000)

;      WEnd

        Turnoff() ;added this line so you do not have to wait until 11pm to test it

EndFunc

Func Turnoff()

SplashTextOn("Shutting Down", "The Computer is Shutting Down", -1, 40, -1, -1, 1, "arial", 24, 500)

  For $n = 1 to 3

  For $i = 1 to 3

  Run(@ComSpec & " /c echo " & Chr(7), "", @SW_HIDE)

  Sleep(250)

  Next

    Sleep(500)

  Next

SplashOff()

HotKeySet("{Esc}", "Cancel") 

ProgressOn("Shutdown", "Shutting Down - Press Esc to cancel", "Shutting Down")

For $i = 1 to 300 step 1

    Sleep(1000)

;>>> Define variables for min, sec

  $x= 300-$i

  $x= $x/60

  $min= StringLeft($x, 1)

  $sec= StringTrimLeft($x, 1)

  $sec= $sec*60

  $sec= Round($sec)

;>>> Set the progress meter to move 1/3 normal speed <to reach 300% = 300 seconds>

  ProgressSet( $i/3, $min & " Minutes and " & $sec & " Seconds to Shutdown", "Shutting Down - Press Esc to cancel")

  If StringRight($sec, 1) = 0 OR StringRight($sec, 1) = 5 Then Run(@ComSpec & " /c echo " & Chr(7), "", @SW_HIDE)

Next

ProgressSet(0 , "Shutting Down", "Shutting Down...")

Sleep(1000)

ProgressOff()

HotKeySet("{Esc}")

Shutdown(13)

Check()

EndFunc

Func Cancel()

HotKeySet("{Esc}")

ProgressOff()

Msgbox(0, "Canceled", "Shutdown Canceled", 3)

Sleep(600000)

Check()

EndFunc

Func Nap()

Sleep(600000)

Check()

EndFunc

Link to comment
Share on other sites

Valuater, the script that is calling the progress bar is running as a machine startup script. If the user did what they were supposed to do, i.e. reboot when they leave for the day, I would not have to worry about showing a progress. But since the script is running at startup, they don't even see the crtl/Alt/del screen.

SerialKiller,

Thanks, I will take a look at that, looks like what I am wanting to do.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...