Bonjour/Bonsoir,
Voici comment envoyé un (ou des) argument(s) de [HTA à VBS] | [VBS à HTA]


**** Envoie argument HTA à VBS ****
Le HTA :
Code HTA : 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
<head>
    <HTA:APPLICATION
        ID="myhta" 
        APPLICATIONNAME="HTA Test"
    >
</head>
 
<script language="VBScript">
    
TestVar1 = Inputbox ("Que veut tu envoyé au vbs ? [HTA argument to VBS")
Dim strParams
strParams = strParams & " " & Chr(34) & TestVar1 & Chr(34)
Set WS = CreateObject("WScript.Shell")
WS.Run "MY.vbs" & strParams
 
</script>

Le VBS (nommé MY.vbs) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
Set Shell = CreateObject("WScript.Shell")
If WScript.Arguments.Length >0 Then 
  Shell.Popup "L'argument reçu est : " &  WScript.Arguments.Item(0)  
Else 
  Shell.Popup "No argument specified."  
End If
**** Fin Envoie argument HTA à VBS ****


**** Envoie argument VBS à HTA ****
Le VBS :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
TestVar1 = Inputbox ("Que veut tu envoyé au HTA ? [VBS argument to HTA")
Dim strParams
strParams = strParams & " " & Chr(34) & TestVar1 & Chr(34)
Set WS = Wscript.CreateObject("WScript.Shell")
WS.Run "myhta.hta" & strParams

Le HTA (nommé myhta.hta) :
Code HTA : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<head>
    <HTA:APPLICATION
        ID="myhta" 
        APPLICATIONNAME="myhta"
    >
</head>
 
<script language="VBScript">
    
    Sub Window_OnLoad()
        a = Split(myhta.CommandLine, Chr(34))
        MsgBox "L'argurment est = " & a(3)
    End Sub
</script>
**** Fin Envoie argument VBS à HTA****