Jump to content

Problem with big files over network


Go to solution Solved by colombeen,

Recommended Posts

Hi guys

Have bit of a problem. I use the ShellExecute function to start some driver setups but the time it takes for some drivers to give you some setup screen takes a long time and i'm wondering if someone knows a good way how to show in a gui that the user has to wait a bit until the setup starts. Like a loading screen or something.

Any ideas?


Link to comment
Share on other sites

This would be one way, but then the splash disappears the moment it loses focus (for examle: the user clicks on something else). Maybe somebody else knows a better way to do this^^

#include <AutoItConstants.au3>
#include <FontConstants.au3>

Local $splash = SplashTextOn('Setup Splash', 'Loading Setup. Please wait.', 350, 100, -1, -1, $DLG_NOTONTOP + $DLG_MOVEABLE + $DLG_TEXTVCENTER, '', 16, $FW_EXTRABOLD)
WinActivate('Setup Splash') ; Otherwise it's not focussed!?
;~ ShellExecute your setup

While 1
    If Not WinActive('Setup Splash') Then ExitLoop

Edited by saudumm
Link to comment
Share on other sites

You can wait for a window associated with the setup process.

For example :

Local $splash = SplashTextOn('Setup Splash', 'Loading Setup. Please wait.', 350, 50, -1, -1)
$iPid = ShellExecute("\\server\share\driver\setup.exe")

; #FUNCTION# ====================================================================================================================
; Name ..........: _WinWaitPID
; Description ...: Pauses execution of the script until a window associated with the specifed PID exists
; Syntax ........: _WinWaitPID($iPid[, $iFlagActive = 0[, $iTimeout = 0]])
; Parameters ....: $iPid                - Process ID (PID).
;                  $iFlagActive         - [optional] . 0 = (default) Returns as soons as the window appears.
;                                                      1 = Waits for the window to be active.
;                  $iTimeout            - Timeout in seconds if the window does not exist. Default is 0 (no timeout).
; Return values .: Success = a handle to the window.
;                  Failure = 0 if timeout occured
; Author ........: jguinch
; ===============================================================================================================================
Func _WinWaitPID($iProcessID, $iFlagActive = 0, $iTimeout = 0)
    Local $hTimer = TimerInit()
    $iTimeout = $iTimeout * 1000

    While 1
        If $iTimeout AND $hTimer >= $iTimeout Then Return 0

        Local $aWinList = WinList()
        For $i = 1 To $aWinList[0][0]
            If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then
                If WinGetProcess($aWinList[$i][1]) = $iProcessID Then
                    If $iFlagActive Then
                        If WinActive($aWinList[$i][1]) Then Return $aWinList[$i][1]
                        Return $aWinList[$i][1]


EndFunc ; ===> _WinWaitPID
Link to comment
Share on other sites

It's isn't neccesairy anymore. With the SplashTextOn, it was easy. Just put the code to hide the splashtexton after the shellexecute and when the notification pops up to allow the installation, and you accept, it just dissapears :-) so it's fixed. Thx everybody :-)

the only thing that would have been better is that i could show how much has been loaded... but i don't think that's something thats easily doable.

Edited by colombeen
Link to comment
Share on other sites

  • Solution

No I didn't need the focus part anymore.

I did : 

-> show splash

-> shellexecute

-> hide splash

hiding the splash gets called right after you get the "do you want to install"-notification from the driver setup.

this because the script just waits for the notification to popup, and continues after that

but maybe i could change it to copy the file to %temp% with a progress bar and then execute it.


EDIT : now I found this piece of code on the forum : 

_FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")

Func _FileCopy($fromFile,$tofile) 
    Local $FOF_RESPOND_YES = 16
    $winShell = ObjCreate("shell.application")

only 1 problem... the script just continues while the copy is still going. anyone who knows how to change this function into a "wait until completed before going any further"-function?

EDIT AGAIN : I found a solution : 

_FileCopy ($serverLocation & "\" & $file, @TempDir)
While 1
    If FileExists (@TempDir & "\" & $file) Then
        If FileGetSize (@TempDir & "\" & $file) = FileGetSize ($serverLocation & "\" & $file) Then
    Sleep (1000)
ShellExecute (@TempDir & "\" & $file)
Edited by colombeen
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

  • Recently Browsing   0 members

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