Vbs/hta - probleme avec une boucle

fplus39 Messages postés 4 Date d'inscription mardi 30 septembre 2008 Statut Membre Dernière intervention 31 mai 2013 - 31 mai 2013 à 16:02
 fabiendag - 13 juin 2013 à 16:15
bonjour,
J'essaie de faire un script en hta pour lancer differents exe avec un délai défini entre chaque, les parametres etant dans un csv.
Mais j'ai un souci:
avant que la boucle ne se lance, j'ai un texte qui doit s'afficher.
Puis ma boucle execute les differents run avec les délais impartis et un texte d'accompagnement
Puis un autre texte apparait
puis la fenetre se ferme

Sauf qu'en fait, mes programmes se lancent tous en même temps dès le lancement du script, puis apparaissent avec les bons délais le texte d'intro (avant boucle), les textes d'accompagnement puis... plus rien.

Mes problèmes sont donc:
-Que la boucle attende que le texte d'intro (sub welcome) s'affiche
-que la boucle lance les exe les un apres les autres en respectant le délai
-qu'une fois la boucle finie, le script continue pour afficher le texte et ferme la fenetre

je vous met mon cvs:
Horloge,Nom,Delai,Soft,Resultat
MonTimer1,Start01,10000,C:\Program Files\IZArc\IZArc.exe,Izarc a bien été lancé
MonTimer2,Start02,15000,C:\Program Files\Moffsoft FreeCalc\MoffFreeCalc.exe,La calculatrice a bien été lancée


le code du hta:
<!-- ----- ExeScript Options Begin -----
 ScriptType: window,invoker
 DestDirectory: temp
 Icon: D:\Bureau\startapp.bmp
 File: D:\Bureau\startapp.bmp
 OutputFile: D:\Bureau\test.exe
 ----- ExeScript Options End ----- -->

<head>
<title>Start App</title>

<HTA:APPLICATION
  APPLICATIONNAME="Start App"
  ID="startapp"
  VERSION="1.2"
  MAXIMIZEBUTTON="no"
  ICON="startapp.ico"
  SCROLL="no"
  SINGLEINSTANCE="yes"
  SELECTION="no"/>

<SCRIPT TYPE="text/javascript">
window.resizeTo(350,275);
window.moveTo(10,10);
</SCRIPT>

    <SCRIPT language="vbscript">
Dim WshShell

        Sub Window_onLoad
            StartTimer      
        End Sub

Sub StartTimer
MonTimer0 =window.setTimeOut ("welcome", 1000, "VBScript") 'Appel de MonScript
End sub

Sub Welcome
S = SetTimeOut("MaSub (""Vos applications vont se lancer dans un instant... Veuillez patienter..."")", 100)
End Sub		


Dim Horloge
Dim Nom
Dim Delai
Dim Soft
Dim Resultat

Dim aVars 
aVars = Array( "Horloge", "Nom", "Delai", "Soft", "Resultat" ) 

Dim oFSO
Set oFSO = CreateObject( "Scripting.FileSystemobject" )

Const INPUT_FILE = "StartApp.csv"
Dim oStream
Dim sData
Dim aData



Set oStream = oFSO.OpenTextFile( INPUT_FILE )

oStream.SkipLine
Do While oStream.AtEndOfStream = True
    sData = oStream.ReadLine
    aData = Split( sData, "," )
    For i = 0 To UBound( aData ) 
        Execute aVars( i ) & " = " & Chr( 34 ) & aData( i ) & Chr( 34 ) 
    Next 
    'At this point all the vars referred to in aVars have the values
    'of the current record

'START APP

    'WSCript.Echo Horloge, Nom, Delai, Soft, Resultat



Set WshShell = CreateObject ("Wscript.Shell")
WshShell.Run Chr(34) & soft

Call SetTimeOut("MaSub (" & Chr(34) & Resultat & Chr(34) & ")", Delai)	


Loop

oStream.Close

Sub StartTimerbis
            MonTimer6 = window.setTimeOut ("Startend", 5000, "VBScript") 'Appel de MonScript 
            MonTimer7 = window.setTimeOut ("Startclose", 10000, "VBScript") 'Appel de MonScript 
        End sub

Sub Startend
S = SetTimeOut("MaSub (""toutes les applications ont été correctement lancées !"")", 100)
End Sub

Sub Startclose
window.close()
End Sub

Set WshShell = nothing

</SCRIPT>



</head>



<center>  </center>





<center>




<script language = vbs>
Sub MaSub (E)
Document.All.D.innerHTML = E
ClearTimeOut S
End Sub
</script>
</center>





</html>

2 réponses

fplus39 Messages postés 4 Date d'inscription mardi 30 septembre 2008 Statut Membre Dernière intervention 31 mai 2013
31 mai 2013 à 16:03
pardon, j'ai cliqué trop vite..
Merci d'avance si vous pouvez m'aider
0
Bonjour a toi,
je crois qu'il y a la méthode sleep en vbscript. Sinon je sais qu'en vba on utilise wait


Fabien
0
Rejoignez-nous