IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Comment Ouvrir un fichier swf avec IE en VBScript ?


Sujet :

VBScript

  1. #1
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 839
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 839
    Points : 9 222
    Points
    9 222
    Par défaut Comment Ouvrir un fichier swf avec IE en VBScript ?
    à Tous !
    J'ai ce Vbscript qui me télécharge un fichier swf depuis mon site web et qui marche très bien.
    Mon but est comment puis-je modifier ce script pour me faire ouvrir mon fichier swf avec Internet Explorer après avoir le télécharger ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    Dim strFileURL,strHDLocation
    ' Mes paramètres 
        strFileURL = "http://hackoo.ifrance.com/M5.swf"
        strHDLocation = "c:\Merlin.swf"
    ' Récupérer le fichier
        Set Ws = CreateObject("WScript.Shell")
        Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
        objXMLHTTP.open "GET", strFileURL, false
        objXMLHTTP.send()
    If objXMLHTTP.Status = 200 Then
    Set objADOStream = CreateObject("ADODB.Stream")
    objADOStream.Open
    objADOStream.Type = 1 'adTypeBinary
    objADOStream.Write objXMLHTTP.ResponseBody
    objADOStream.Position = 0    'Set the stream position to the start
    Set objFSO = Createobject("Scripting.FileSystemObject")
    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
    Set objFSO = Nothing
    objADOStream.SaveToFile strHDLocation
    objADOStream.Close
    Set objADOStream = Nothing
    End If
    Set objXMLHTTP = Nothing 
    Ws.Run strHDLocation 
    Set Ws = Nothing

  2. #2
    Expert éminent sénior


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Points : 20 038
    Points
    20 038
    Par défaut
    L'automation te permet de piloter IE :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Dim IE
    Set IE = Wscript.CreateObject("InternetExplorer.Application")
    IE.Visible = 1 
    IE.navigate "c:\Merlin.swf"
    Do While (IE.Busy)
        WScript.Sleep 10
    Loop

  3. #3
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 839
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 839
    Points : 9 222
    Points
    9 222
    Par défaut
    Citation Envoyé par bbil Voir le message
    L'automation te permet de piloter IE :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Dim IE
    Set IE = Wscript.CreateObject("InternetExplorer.Application")
    IE.Visible = 1 
    IE.navigate "c:\Merlin.swf"
    Do While (IE.Busy)
        WScript.Sleep 10
    Loop
    bbil oui c'est une solution mais il me sort une Boîte de dialogue de téléchargement "Ouvrir","Enregistrer" ,"Annuler" que je n'ai pas besoin mais je veux qu'il me lit ce SWF directement avec IE sans Boîte de dialogue ou de confirmation après un téléchargement discret.Alors j'ai trouvé mieux et dans une seule ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Ws.Run "%comspec% /c Start iexplore " & strHDLocation, 0, 1
    et le Script devient alors comme ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    Dim strFileURL,strHDLocation
    ' Mes paramètres 
        strFileURL = "http://hackoo.ifrance.com/M5.swf"
        strHDLocation = "c:\Merlin.swf"
    ' Récupérer le fichier
        Set Ws = CreateObject("WScript.Shell")
        Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
        objXMLHTTP.open "GET", strFileURL, false
        objXMLHTTP.send()
    If objXMLHTTP.Status = 200 Then
    Set objADOStream = CreateObject("ADODB.Stream")
    objADOStream.Open
    objADOStream.Type = 1 'adTypeBinary
    objADOStream.Write objXMLHTTP.ResponseBody
    objADOStream.Position = 0    'Set the stream position to the start
    Set objFSO = Createobject("Scripting.FileSystemObject")
    If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
    Set objFSO = Nothing
    objADOStream.SaveToFile strHDLocation
    objADOStream.Close
    Set objADOStream = Nothing
    End If
    Set objXMLHTTP = Nothing 
    Ws.Run "%comspec% /c Start iexplore " & strHDLocation, 0, 1 
    Set WS = Nothing

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Comment ouvrir un fichier créé avec MemoryStream
    Par david87 dans le forum Windows Forms
    Réponses: 7
    Dernier message: 20/08/2013, 23h12
  2. Comment ouvrir un fichier excel avec une commande batch ?
    Par Alexandrebox dans le forum Scripts/Batch
    Réponses: 1
    Dernier message: 18/03/2010, 13h15
  3. Comment ouvrir un fichier archivé avec FILESTREAM
    Par launay dans le forum Langage
    Réponses: 4
    Dernier message: 18/12/2009, 21h55
  4. Comment ouvrir un fichier .xla avec excel ?
    Par Australia dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 14/11/2006, 18h08
  5. comment ouvrir un fichier XML avec excel
    Par ALCINA dans le forum XML/XSL et SOAP
    Réponses: 7
    Dernier message: 24/03/2006, 14h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo