wklw2005

Process Bar with RunWiat

6 posts in this topic

ProgressOn("Company", "CADWorx 2015", "Working...")
$System Variable = EnvGet("System Variable")

RunWait($System Variable & "\Intergraph\CADWorx 2015\CADWorx_2015\setup.exe /s /f1C:\Temp\CADWorx2015_ACAD2015_64_CH.iss")

For $i = 1 To 100 Step 1
    Sleep(1790)
    ProgressSet($i, $i & " %")
Next
ProgressSet(100, "Almost Done....")
Sleep(550)
ProgressOff()

I need to create a silent install for a design software. I've created the answer file and it will run file. I am creating this to the read system variable on the machine bc we have other offices. I realize this will not be a silent install with a process bar but it's what's required. I would like to use the runwait command due to the script having a few hotfixes to install after. The issues I am having is, if I use just the Run command and the process bar process ends before the install is complete due to network issues or whatever we get errors and the hotfixes will not install next. If I use the runwait command, the design software will install and then the process bar will kick off.

Please help..

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You need to do a run, get the output of the command (the pid), and factor that into your loop (ProcessExists).

You also might want to continually scale up the sleep time, to compensate for your slower connection comps.  The only reason you should ever hit 100 is because the process closes.

Of course, when the PID exits, exit your loop, and set instantly to 100.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The idea is in your function the progress bar doesn't start until after the executable is installed. You need to add the hot fixes in after the initial runwait. The problem is your progress bar is in no way tied to the installation besides just the run wait. HERE'S the order of events runwait then program installs. Bar rolls then exits. If you use run the program begins to install then the bar rolls and exits. The bar will progress regardless of what happens bc it's just a pointless loop taking no cues from anything else happening around it...

I'm not really familiar with this exact line of coding but setting the loop to check for specific files in the install directory could be used for cues to the progress bar as to how far to scroll.

I.e for $1 to 100

Bla Bla

If fileexists (@programfilesdir & "pathtofilefile.fil) and $i<20 then

$i=20

Else $i=19

Endif

Next

And so on

Edit I guess the above concept may possibly work using the run command it would not work with runwait.

Edit I been thinking about this and if you would say install the program and then write a small script to say generate a file list.txt. then tie that to the progress bar using a file read loop. Then say get a count of how many files in the list vs how many are actually installed would be your %. I guess it just depends on how crazy you want to get with this.

Edit. Upon further review if you could just figure out how many files your installing vs how many files are in the new install directory there's your %. I think that's simple enough. No need to compare strings ect.

Edited by markyrocks

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Simple example...close notepad to mimic the installer completing:

Global $iPid

; because the sleep can become VERY long...i'd suggest adding this in to constantly check, despite the sleep occuring
AdlibRegister("CheckPID",100)

ProgressOn("Company", "CADWorx 2015", "Working...")

$iPid = Run("notepad")

$iSleep = 100
For $i = 1 To 100 Step 1
    Sleep($iSleep)
    If Not ProcessExists($iPid) Then ExitLoop
    ProgressSet($i, $i & " %")
    $iSleep=$iSleep*1.10 ; increase sleep 10%...compounded
    ConsoleWrite($iSleep & @CRLF)
Next

Func CheckPID()
    If $iPid Then
        If $iPid And Not ProcessExists($iPid) Then
            ProgressSet(100, "Almost Done....")
            Sleep(5000)
            ProgressOff()
            AdlibUnRegister("CheckPID")
        EndIf
    EndIf
EndFunc
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

It would probably be better to just use the GUICtrlCreateProgress function instead and use the $PBS_MARQUEE style on it. Seeing as how the progress bar's position along it will be arbitrary anyways, why not use something designed for this?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

thanks for your help!!!

Share this post


Link to post
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