Problème avec le If Then

polowiper Messages postés 2 Statut Membre -  
yg_be Messages postés 23437 Date d'inscription   Statut Contributeur Dernière intervention   -
bonjour voila mon code en .vbs
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
code = "123-456-789"
InputBox "Entrer le code ici 1/2 essais", "test", "xxx-xxx-xxx"
If input=code Then
Set oWShell = CreateObject("Wscript.Shell")
oWShell.Run """C:\Desktop\fichier.bat""", 0, False
Set oWSHell = Nothing

InputBox "Entrer le code ici 2/2 essais", "test", "xxx-xxx-xxx"
If input=code Then
Set oWShell = CreateObject("Wscript.Shell")
oWShell.Run """C:\Desktop\fichier.bat""", 0, False
Set oWSHell = Nothing
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ici le but et d'entrer un code dans une "inputbox" et si le code et bon un fichier en .bat s’exécute je pense que le problème viens de la ligne:

If input=code Then

voici le code d'erreur:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Script: C:\Desktop\Test.vbs
Ligne: 13
Caract: 1
Erreur: 'End' Attendu
Code: 800A03F6
Source: Erreur de compilation Microsoft
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Merci d'avance

3 réponses

  1. yg_be Messages postés 23437 Date d'inscription   Statut Contributeur Dernière intervention   Ambassadeur 1 588
     
    bonjour, il faut terminer les
    if
    par des
    end if
    .
    exemple:
    If inputt = code Then
        Set oWSHell = CreateObject("Wscript.Shell")
        oWSHell.Run """C:\Desktop\fichier.bat""", 0, False
        Set oWSHell = Nothing
    End If
    0
  2. polowiper Messages postés 2 Statut Membre
     
    merci cependant j'aimerais connaitre la commande pour les inputs car le fichier marche très bien maintenant mais quand j'entre le code il ne se passe rien
    voila à quoi ressemble le fichier maintenant:

    
    code = "123-456-789"
    InputBox "Entrer le code ici 1/2 essais", "test", "xxx-xxx-xxx"
    If input = code Then
    Set oWShell = CreateObject("Wscript.Shell")
    oWShell.Run """C:\Desktop\fichier.bat""", 0, False
    Set oWSHell = Nothing
    End if
    InputBox "Entrer le code ici 2/2 essais", "test", "xxx-xxx-xxx"
    If input = code Then
    Set oWShell = CreateObject("Wscript.Shell")
    oWShell.Run """C:\Desktop\fichier.bat""", 0, False
    Set oWSHell = Nothing 
    End if
    <code basic>
    </code>
    0
    1. yg_be Messages postés 23437 Date d'inscription   Statut Contributeur Dernière intervention   1 588
       
      c'est normal, puisque tu ne fais rien avec la réponse de inputbox.
      sans doute:
      input =  InputBox ("Entrer le code ici 1/2 essais", "test", "xxx-xxx-xxx")
      0