Problème avec le If Then

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

  • Votes
  • Date
  • Date décroissante
  1. Contributeur
    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
    1. 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>
      1. Contributeur
        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")