Jump to content

Recommended Posts

Posted

I'm having trouble with InetGet.
I want to lose the Silverlight.exe with InetGet of this page --- http :/ / www.microsoft.com / getSilverlight / handlers / getsilverlight.ashx
but not successful because the product does not end in. exe file and thus not low at all.
The idea of my script is to download and install the latest vercion of Silverlight.exe
This is part of my code:

#include <Math.au3>
    #include <GUIConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    TraySetState (2)
    $_FinalUrl = 'http://www.microsoft.com/getsilverlight/handlers/getsilverlight.ashx'
    $_TempPath = @TempDir & '\Silverlight_Instaler.exe'
    $_FileSize = InetGetSize ( $_FinalUrl )
    $_Gui = GUICreate ("DOWNLOAD...", 359, 114, 260, 138)
    GUISetIcon("@TempDir & '\Silverlight.ico", -1)
    GUICtrlCreateLabel("MICROSOFT SILVERLIGHT", 32, 16, 300, 25, $SS_CENTER)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $_ProgressBar = GUICtrlCreateProgress (48, 40, 254, 33, $PBS_SMOOTH)
    GUISetState ( @SW_SHOW )
    $_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1)
    Local $_InfoData
    Do
        $_InfoData = InetGetInfo ( $_Download )
        If Not @error Then
           $_InetGet = $_InfoData[0]
           $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize )
           $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 )
           GUICtrlSetData ( $_ProgressBar, $_DownloadPercent )
           $_Label = GUICtrlCreateLabel ( 'PROGRESS : ' & $_DownloadPercent & ' %', 32, 88, 308, 17, $SS_CENTER )
           GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
        EndIf
        Sleep ( 100 )
    Until $_InfoData[2] = True
    $_Label = GUICtrlCreateLabel ( 'DOWNLOAD SUCCESSFULL !', 32, 88, 308, 17 , $SS_CENTER)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    Sleep ( 2000 )
    $_Label = GUICtrlCreateLabel ( 'INSTALANDO ESPERE... !', 32, 88, 308, 17 , $SS_CENTER)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    Sleep ( 2000 )

    ShellExecuteWait(@TempDir & '\Silverlight_Instaler.exe' , '/q /doNotRequireDRMPrompt /ignorewarnings')

If someone has a great maid solution because all neurons burn no avail.

Sorry for my bad English.

Posted

You just have to get the real location of the url using WinHttp.au3 and it works !  ;) 

#include <Math.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>

#include <WinHTTP.au3> ; <<<<<<<<< http://code.google.com/p/autoit-winhttp/downloads/list

TraySetState (2)
$_FinalUrl = 'http://www.microsoft.com/getsilverlight/handlers/getsilverlight.ashx'
$_FinalUrl = _WinHttpGetLocation ( $_FinalUrl )
ConsoleWrite ( 'Location : ' & $_FinalUrl & @Crlf )
$_TempPath = @TempDir & '\Silverlight_Instaler.exe'
$_FileSize = InetGetSize ( $_FinalUrl )
$_Gui = GUICreate ("DOWNLOAD...", 359, 114, 260, 138)
GUISetIcon("@TempDir & '\Silverlight.ico", -1)
GUICtrlCreateLabel("MICROSOFT SILVERLIGHT", 32, 16, 300, 25, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$_ProgressBar = GUICtrlCreateProgress (48, 40, 254, 33, $PBS_SMOOTH)
GUISetState ( @SW_SHOW )
$_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1)
Local $_InfoData
Do
    $_InfoData = InetGetInfo ( $_Download )
    If Not @error Then
        $_InetGet = $_InfoData[0]
        $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize )
        $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 )
        GUICtrlSetData ( $_ProgressBar, $_DownloadPercent )
        $_Label = GUICtrlCreateLabel ( 'PROGRESS : ' & $_DownloadPercent & ' %', 32, 88, 308, 17, $SS_CENTER )
        GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    EndIf
    Sleep ( 100 )
Until $_InfoData[2] = True
$_Label = GUICtrlCreateLabel ( 'DOWNLOAD SUCCESSFULL !', 32, 88, 308, 17 , $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Sleep ( 2000 )
$_Label = GUICtrlCreateLabel ( 'INSTALANDO ESPERE... !', 32, 88, 308, 17 , $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Sleep ( 2000 )

ShellExecuteWait(@TempDir & '\Silverlight_Instaler.exe' , '/q /doNotRequireDRMPrompt /ignorewarnings')
Exit

Func _WinHttpGetLocation ( $sUrl )
    Local $hOpen, $hConnect, $hRequest, $sHostName, $sFileName, $sLocation
    Local $aCrackedUrl = _WinHttpCrackUrl ( $sUrl, $ICU_DECODE )
    $hOpen = _WinHttpOpen ( 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)' )
    _WinHttpSetOption ( $hOpen, $WINHTTP_OPTION_REDIRECT_POLICY, $WINHTTP_OPTION_REDIRECT_POLICY_NEVER )
    $sHostName = $aCrackedUrl[2]
    $hConnect = _WinHttpConnect ( $hOpen, $sHostName, $aCrackedUrl[3] )
    $sFileName = $aCrackedUrl[6] & $aCrackedUrl[7]
    $hRequest = _WinHttpOpenRequest ( $hConnect, 'GET', $sFileName, 'HTTP/1.1', $sHostName )
    _WinHttpAddRequestHeaders ( $hRequest, 'Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/msword, */*' )
    _WinHttpAddRequestHeaders ( $hRequest, 'Accept-Encoding: gzip, deflate' )
    _WinHttpAddRequestHeaders ( $hRequest, 'Connection: Keep-Alive' )
    _WinHttpSendRequest ( $hRequest )
    _WinHttpReceiveResponse ( $hRequest )
    If _WinHttpQueryDataAvailable ( $hRequest ) Then $sLocation = _WinHttpQueryHeaders ( $hRequest, $WINHTTP_QUERY_LOCATION )
    _WinHttpCloseHandle ( $hRequest )
    _WinHttpCloseHandle ( $hConnect )
    _WinHttpCloseHandle ( $hOpen )
    Return $sLocation
EndFunc ;==> _WinHttpGetLocation ()

AutoIt 3.3.18.0 X86 - SciTE 4.4.6.0WIN 11 24H2 X64 - Other Examples Scripts

Posted

 

You just have to get the real location of the url using WinHttp.au3 and it works !  ;) 

#include <Math.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>

#include <WinHTTP.au3> ; <<<<<<<<< http://code.google.com/p/autoit-winhttp/downloads/list

TraySetState (2)
$_FinalUrl = 'http://www.microsoft.com/getsilverlight/handlers/getsilverlight.ashx'
$_FinalUrl = _WinHttpGetLocation ( $_FinalUrl )
ConsoleWrite ( 'Location : ' & $_FinalUrl & @Crlf )
$_TempPath = @TempDir & '\Silverlight_Instaler.exe'
$_FileSize = InetGetSize ( $_FinalUrl )
$_Gui = GUICreate ("DOWNLOAD...", 359, 114, 260, 138)
GUISetIcon("@TempDir & '\Silverlight.ico", -1)
GUICtrlCreateLabel("MICROSOFT SILVERLIGHT", 32, 16, 300, 25, $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$_ProgressBar = GUICtrlCreateProgress (48, 40, 254, 33, $PBS_SMOOTH)
GUISetState ( @SW_SHOW )
$_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1)
Local $_InfoData
Do
    $_InfoData = InetGetInfo ( $_Download )
    If Not @error Then
        $_InetGet = $_InfoData[0]
        $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize )
        $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 )
        GUICtrlSetData ( $_ProgressBar, $_DownloadPercent )
        $_Label = GUICtrlCreateLabel ( 'PROGRESS : ' & $_DownloadPercent & ' %', 32, 88, 308, 17, $SS_CENTER )
        GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    EndIf
    Sleep ( 100 )
Until $_InfoData[2] = True
$_Label = GUICtrlCreateLabel ( 'DOWNLOAD SUCCESSFULL !', 32, 88, 308, 17 , $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Sleep ( 2000 )
$_Label = GUICtrlCreateLabel ( 'INSTALANDO ESPERE... !', 32, 88, 308, 17 , $SS_CENTER)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
Sleep ( 2000 )

ShellExecuteWait(@TempDir & '\Silverlight_Instaler.exe' , '/q /doNotRequireDRMPrompt /ignorewarnings')
Exit

Func _WinHttpGetLocation ( $sUrl )
    Local $hOpen, $hConnect, $hRequest, $sHostName, $sFileName, $sLocation
    Local $aCrackedUrl = _WinHttpCrackUrl ( $sUrl, $ICU_DECODE )
    $hOpen = _WinHttpOpen ( 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)' )
    _WinHttpSetOption ( $hOpen, $WINHTTP_OPTION_REDIRECT_POLICY, $WINHTTP_OPTION_REDIRECT_POLICY_NEVER )
    $sHostName = $aCrackedUrl[2]
    $hConnect = _WinHttpConnect ( $hOpen, $sHostName, $aCrackedUrl[3] )
    $sFileName = $aCrackedUrl[6] & $aCrackedUrl[7]
    $hRequest = _WinHttpOpenRequest ( $hConnect, 'GET', $sFileName, 'HTTP/1.1', $sHostName )
    _WinHttpAddRequestHeaders ( $hRequest, 'Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/msword, */*' )
    _WinHttpAddRequestHeaders ( $hRequest, 'Accept-Encoding: gzip, deflate' )
    _WinHttpAddRequestHeaders ( $hRequest, 'Connection: Keep-Alive' )
    _WinHttpSendRequest ( $hRequest )
    _WinHttpReceiveResponse ( $hRequest )
    If _WinHttpQueryDataAvailable ( $hRequest ) Then $sLocation = _WinHttpQueryHeaders ( $hRequest, $WINHTTP_QUERY_LOCATION )
    _WinHttpCloseHandle ( $hRequest )
    _WinHttpCloseHandle ( $hConnect )
    _WinHttpCloseHandle ( $hOpen )
    Return $sLocation
EndFunc ;==> _WinHttpGetLocation ()

 

Thanks for the code, works :thumbsup:

Achievement download the file, but I can not run it as I said it is not a valid win32 application, I think it's for the 64-bit version, when I use the link in the browser I download the correct vercion.

You will have idea why this happens?

Thank you very much for your time and dedication

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
×
×
  • Create New...