IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Automatisation telnet et copie vers fichier text


Sujet :

VBScript

  1. #1
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut Automatisation telnet et copie vers fichier text
    Bonjour j'ai parcouru le forum sans succès j'ai un problème à résoudre très vite j'espère trouver une solution. Voici ma préoccupation, j'ai écrit un script qui automatise le telnet, mais je n'arrive pas à mettre le résultat dans un fichier texte et je doit aussi préciser que le script ne se ferme pas après exécution voici le script en question, il est long donc je le réduit
    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
    Dim objShell 
    Set objShell = CreateObject("WScript.Shell") 
    objShell.Run "C:\Windows\System32\telnet.exe 10.10.3.1",,False 
    WScript.Sleep 100
    objShell.SendKeys "admin~" 
    WScript.Sleep 100
    objShell.SendKeys "1" 
    WScript.Sleep 100
    objShell.SendKeys "1~" 
    WScript.Sleep 100
    objShell.SendKeys "4" 
    WScript.Sleep 100
    objShell.SendKeys "2" 
    WScript.Sleep 100
    objShell.SendKeys "1~" 
    WScript.Sleep 100
    objShell.SendKeys "^z" 
    WScript.Sleep 100
    objShell.SendKeys "1"
    WScript.Sleep 100
    objShell.SendKeys "4"
    WScript.Sleep 100
    objShell.SendKeys "3"
    WScript.Sleep 100
    objShell.SendKeys "1"
    WScript.Sleep 100
    objShell.SendKeys "^z"
    WScript.Sleep 100
    objShell.SendKeys "1"
    WScript.Sleep 100
    objShell.SendKeys "4"
    WScript.Sleep 100
    objShell.SendKeys "3"
    WScript.Sleep 100
    objShell.SendKeys "1"
    WScript.Sleep 100
    objShell.SendKeys "^z"
    J'attend vos réactions merci d'avance

  2. #2
    Membre expérimenté
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Novembre 2011
    Messages
    163
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Novembre 2011
    Messages : 163
    Par défaut
    Bonjour,
    Il me semble que l'option -f de telnet permet de créer un fichier log :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objShell.Run "C:\Windows\System32\telnet.exe 10.10.3.1 -f log.txt",False
    Edit : Ah j'ai raté la deuxième partie de la question !
    Personnellement je terminerai le script par :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objShell.SendKeys "exit~"

  3. #3
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    Citation Envoyé par Cachlab Voir le message
    Bonjour,
    Il me semble que l'option -f de telnet permet de créer un fichier log :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objShell.Run "C:\Windows\System32\telnet.exe 10.10.3.1 -f log.txt",False
    Edit : Ah j'ai raté la deuxième partie de la question !
    Personnellement je terminerai le script par :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objShell.SendKeys "exit~"
    Merci ça marche très bien mais j'ai réussi à sortir du telnet d'une autre manière.
    j'ai une autre préoccupation j'ai en fait 61 fichiers textes qui doivent être créé à partir de 61 adresses IP différentes par exemple,
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    10.10.3.1, 10.10.3.2, 10.10.5.1, 10.10.1, 10.10.7.5, 10.10.8.9
    comme ça 61 adresses IP diférentes et qui ne sont pas dans un ordre défini, ma préoccupation est la suivante, est ce que je dois faire 61 script différents ? parce que j'ai envie de les exécuter tous pour ensuite pouvoir les traiter

  4. #4
    Modérateur
    Avatar de l_autodidacte
    Homme Profil pro
    Retraité : Directeur de lycée/Professeur de sciences physiques
    Inscrit en
    Juillet 2009
    Messages
    2 420
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Retraité : Directeur de lycée/Professeur de sciences physiques
    Secteur : Enseignement

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2 420
    Par défaut
    est ce que je dois faire 61 script différents ? parce que j'ai envie de les exécuter tous pour ensuite pouvoir les traiter
    Non, il suffit de les placer dans un fichier .txt une IP par ligne puis lire le fichier ligne par ligne qu'on passera en argument tel que :
    objShell.Run "C:\Windows\System32\telnet.exe Lecture",,False.
    "Lecture" étant la ligne lue. Il va de soit qu'il faut boucler sur la lecture et son traitement.
    Ne pas oublier le tag si satisfait.
    Voter pour toute réponse satisfaisante avec pour encourager les intervenants.
    Balises CODE indispensables. Regardez ICI
    Toujours utiliser la clause Option Explicit(VBx, VBS ou VBA) et Ne jamais typer variables et/ou fonctions en VBS.
    Vous pouvez consulter mes contributions
    Ne pas oublier de consulter les différentes FAQs et les Cours/Tutoriels VB6/VBScript
    Ne pas oublier L'Aide VBScript et MSDN VB6 Fr

  5. #5
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut

    ou bien vous pouvez faire d'une façon plus générale :
    Par exemple vous avez un fichier nommé : Listeip.txt
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    10.10.3.1,10.10.3.2,10.10.5.1,10.10.1,10.10.7.5,10.10.8.9,10.10.8.10,10.10.8.11,10.10.8.12,10.10.8.13,10.10.8.14,10.10.8.15,10.10.8.16,10.10.8.17,10.10.8.18
     
     
    127.0.0.1
    192.168.1.2
    192.777.888.1 ==> Ip Non Valide
    et le script pour extraire les ip valides et les traiter une par une :
    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
    Titre = "Adresse IP"
    Set oFso = CreateObject("Scripting.FileSystemObject")
    If oFso.FileExists("Listeip.txt") Then
        Set f = oFso.OpenTextFile("Listeip.txt",1)
        Data = f.ReadAll
        f.Close
    Else
        MsgBox "une erreur s'est produite lors de la lecture du fichier Listeip.txt",16,"Erreur de Lecture du fichier"
    End If
    Set objRegex = new RegExp
    objRegex.Pattern = "\b((25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(25[0-5]|2[0-4]\d|1?\d?\d)\b"
    objRegex.Global = True
    objRegex.IgnoreCase = True
    Set Matches = objRegex.Execute(Data)
    For Each Match in Matches 
        MsgBox " objShell.Run C:\Windows\System32\telnet.exe " & Match.value & " -f log.txt",64,Titre
    Next

  6. #6
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    rien ne fonctionne actuellement, je voudrais préciser que je voudrais avoir 61 fichier différent pour chaque adresse IP, pour le traitement qui sera enregistré dans la base de données

  7. #7
    Membre chevronné Avatar de pitchalov
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 340
    Par défaut
    Bonjour,
    En reprenant la méthode de hackoofr de manière plus simple (moins de contrôle), voici comment tu pourrais procéder :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    For Each strIP in Split(CreateObject("Scripting.FileSystemObject").oFso.OpenTextFile("Listeip.txt",1).ReadAll, ",")
    	objShell.Run "C:\Windows\System32\telnet.exe " & strIP & " -f " & strIP & "-log.txt",,False
    	WScript.Sleep 100
    	objShell.SendKeys "admin~" 
    	WScript.Sleep 100
    	'...
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    Next
    Bonne continuation

  8. #8
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    il ya une erreur de complilation qui dit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Cet objet ne gère pas cette propriété ou cette méthode
    c'est sur la ligne: 1 caract: 1

  9. #9
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut
    Citation Envoyé par baymard Voir le message
    il ya une erreur de complilation qui dit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Cet objet ne gère pas cette propriété ou cette méthode
    c'est sur la ligne: 1 caract: 1
    Postez votre fichier ou il y a les adresses ip et le script que vous avez utiliser

  10. #10
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    voici le fichier qui contient les adresses IP
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    10.10.3.1, 10.10.3.2, 10.10.3.3, 10.10.3.4, 10.10.3.18, 10.10.3.6, 10.10.3.7, 10.10.3.8, 10.10.3.9, 10.10.3.15, 10.10.3.17, 10.10.3.16, 10.10.3.12, 10.10.3.14, 10.10.3.13, 10.10.3.19, 10.10.3.20, 10.10.3.22, 10.10.3.23, 10.10.3.24, 10.10.3.26, 10.10.3.25, 10.10.5.1, 10.10.5.2, 10.10.5.3, 10.10.5.4, 10.10.5.5, 10.10.5.6, 10.10.5.7, 10.10.5.8, 10.10.5.9, 10.10.5.10, 10.10.5.16, 10.10.5.12, 10.10.5.14, 10.10.5.15, 10.10.5.13, 10.10.5.17, 10.10.5.20, 10.10.5.21, 10.10.8.1, 10.10.5.19, 10.10.5.23, 10.10.5.18, 10.10.5.22, 10.10.5.24, 10.10.5.25, 10.10.7.1, 10.10.7.2, 10.10.7.3, 10.10.7.4, 10.10.7.5, 10.10.8.7, 10.10.8.9, 10.10.8.4, 10.10.8.3, 10.10.8.8, 10.10.8.2, 10.10.8.6, 10.10.8.5, 10.10.8.10.txt
    Maintenant voici mon script
    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
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    For Each strIP in Split(CreateObject("Scripting.FileSystemObject").oFso.OpenTextFile("Listeip.txt",1).ReadAll, ",")
    	objShell.Run "C:\Windows\System32\telnet.exe " & strIP & " -f " & strIP & "-log.txt",,False
    	WScript.Sleep 100
    	objShell.SendKeys "admin~" 
    	WScript.Sleep 100
    	objShell.SendKeys "1" 
    	WScript.Sleep 100
    	objShell.SendKeys "1~" 
    	WScript.Sleep 100
    	objShell.SendKeys "4" 
    	WScript.Sleep 100
    	objShell.SendKeys "2" 
    	WScript.Sleep 100
    	objShell.SendKeys "1~" 
    	WScript.Sleep 100
    	objShell.SendKeys "^z" 
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "4"
    	WScript.Sleep 100
    	objShell.SendKeys "3"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "4"
    	WScript.Sleep 100
    	objShell.SendKeys "3"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "2"
    	WScript.Sleep 100
    	objShell.SendKeys "7"
    	WScript.Sleep 100
    	objShell.SendKeys "3"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "2"
    	WScript.Sleep 100
    	objShell.SendKeys "1~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "4"
    	WScript.Sleep 100
    	objShell.SendKeys "1~"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "5"
    	WScript.Sleep 100
    	objShell.SendKeys "1~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "x"
    	WScript.Sleep 100
    	objShell.SendKeys "y~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	Next

  11. #11
    Membre chevronné Avatar de pitchalov
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 340
    Par défaut
    Bonjour,

    Excusez-moi ma coquille.
    Ca devrait mieux marcher comme ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    For Each strIP in Split(CreateObject("Scripting.FileSystemObject").OpenTextFile("Listeip.txt",1).ReadAll, ",")
         strIP = Trim(strIP)
         objShell.Run "..."
         '... Suite
    Next
    Bonne continuation

  12. #12
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    Citation Envoyé par pitchalov Voir le message
    Bonjour,

    Excusez-moi ma coquille.
    Ca devrait mieux marcher comme ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    For Each strIP in Split(CreateObject("Scripting.FileSystemObject").OpenTextFile("Listeip.txt",1).ReadAll, ",")
         strIP = Trim(strIP)
         objShell.Run "..."
         '... Suite
    Next
    Bonne continuation
    ça ne fonctionne toujours pas

  13. #13
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    Voici mes adresses IP
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    10.10.3.1, 10.10.3.2, 10.10.3.3, 10.10.3.4, 10.10.3.18, 10.10.3.6, 10.10.3.7, 10.10.3.8, 10.10.3.9, 10.10.3.15, 10.10.3.17, 10.10.3.16, 10.10.3.12, 10.10.3.14, 10.10.3.13, 10.10.3.19, 10.10.3.20, 10.10.3.22, 10.10.3.23, 10.10.3.24, 10.10.3.26, 10.10.3.25, 10.10.5.1, 10.10.5.2, 10.10.5.3, 10.10.5.4, 10.10.5.5, 10.10.5.6, 10.10.5.7, 10.10.5.8, 10.10.5.9, 10.10.5.10, 10.10.5.16, 10.10.5.12, 10.10.5.14, 10.10.5.15, 10.10.5.13, 10.10.5.17, 10.10.5.20, 10.10.5.21, 10.10.8.1, 10.10.5.19, 10.10.5.23, 10.10.5.18, 10.10.5.22, 10.10.5.24, 10.10.5.25, 10.10.7.1, 10.10.7.2, 10.10.7.3, 10.10.7.4, 10.10.7.5, 10.10.8.7, 10.10.8.9, 10.10.8.4, 10.10.8.3, 10.10.8.8, 10.10.8.2, 10.10.8.6, 10.10.8.5, 10.10.8.10.txt
    Et ceci c'est le code qui passe lorsque je check une seule adresse
    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
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    Dim objShell 
    Set objShell = CreateObject("WScript.Shell") 
    objShell.Run "C:\Windows\System32\telnet.exe 10.10.3.2 -f logs.txt",,False 
    WScript.Sleep 100
    objShell.SendKeys "admin~" 
    WScript.Sleep 100
    objShell.SendKeys "1" 
    WScript.Sleep 100
    objShell.SendKeys "1~" 
    WScript.Sleep 100
    objShell.SendKeys "4" 
    WScript.Sleep 100
    objShell.SendKeys "2" 
    WScript.Sleep 100
    objShell.SendKeys "1~" 
    WScript.Sleep 100
    objShell.SendKeys "^z" 
    WScript.Sleep 100
    objShell.SendKeys "1"
    WScript.Sleep 100
    objShell.SendKeys "4"
    WScript.Sleep 100
    objShell.SendKeys "3"
    WScript.Sleep 100
    objShell.SendKeys "1"
    WScript.Sleep 100
    objShell.SendKeys "^z"
    WScript.Sleep 100
    objShell.SendKeys "1"
    WScript.Sleep 100
    objShell.SendKeys "4"
    WScript.Sleep 100
    objShell.SendKeys "3"
    WScript.Sleep 100
    objShell.SendKeys "1"
    WScript.Sleep 100
    objShell.SendKeys "^z"
    WScript.Sleep 100
    objShell.SendKeys "1"
    WScript.Sleep 100
    objShell.SendKeys "2"
    WScript.Sleep 100
    objShell.SendKeys "7"
    WScript.Sleep 100
    objShell.SendKeys "3"
    WScript.Sleep 100
    objShell.SendKeys "^z"
    WScript.Sleep 100
    objShell.SendKeys "2"
    WScript.Sleep 100
    objShell.SendKeys "1~"
    WScript.Sleep 100
    objShell.SendKeys "~"
    WScript.Sleep 100
    objShell.SendKeys "~"
    WScript.Sleep 100
    objShell.SendKeys "^z"
    WScript.Sleep 100
    objShell.SendKeys "4"
    WScript.Sleep 100
    objShell.SendKeys "1~"
    WScript.Sleep 100
    objShell.SendKeys "^z"
    WScript.Sleep 100
    objShell.SendKeys "5"
    WScript.Sleep 100
    objShell.SendKeys "1~"
    WScript.Sleep 100
    objShell.SendKeys "~"
    WScript.Sleep 100
    objShell.SendKeys "^z"
    WScript.Sleep 100
    objShell.SendKeys "x"
    WScript.Sleep 100
    objShell.SendKeys "y~"
    WScript.Sleep 100
    objShell.SendKeys "~"

  14. #14
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Set oFso=CreateObject("Scripting.FileSystemObject")
    For Each strIP in Split(oFso.OpenTextFile("Listeip.txt",1).ReadAll, ",")
        strIP = Trim(strIP)
        MsgBox "objShell.Run C:\Windows\System32\telnet.exe " & strIP & " -f " & strIP & "-log.txt"
    Next
    et vous avez à la fin du fichier qui contient les adresses ip une non valide :
    10.10.8.10.txt
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    10.10.3.1, 10.10.3.2, 10.10.3.3, 10.10.3.4, 10.10.3.18, 10.10.3.6, 10.10.3.7, 10.10.3.8, 10.10.3.9, 10.10.3.15, 
     
    10.10.3.17, 10.10.3.16, 10.10.3.12, 10.10.3.14, 10.10.3.13, 10.10.3.19, 10.10.3.20, 10.10.3.22, 10.10.3.23, 
     
    10.10.3.24, 10.10.3.26, 10.10.3.25, 10.10.5.1, 10.10.5.2, 10.10.5.3, 10.10.5.4, 10.10.5.5, 10.10.5.6, 10.10.5.7, 
     
    10.10.5.8, 10.10.5.9, 10.10.5.10, 10.10.5.16, 10.10.5.12, 10.10.5.14, 10.10.5.15, 10.10.5.13, 10.10.5.17, 
     
    10.10.5.20, 10.10.5.21, 10.10.8.1, 10.10.5.19, 10.10.5.23, 10.10.5.18, 10.10.5.22, 10.10.5.24, 10.10.5.25, 
     
    10.10.7.1, 10.10.7.2, 10.10.7.3, 10.10.7.4, 10.10.7.5, 10.10.8.7, 10.10.8.9, 10.10.8.4, 10.10.8.3, 10.10.8.8, 
     
    10.10.8.2, 10.10.8.6, 10.10.8.5, 10.10.8.10

  15. #15
    Membre chevronné Avatar de pitchalov
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    340
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 340
    Par défaut
    Citation Envoyé par baymard Voir le message
    ça ne fonctionne toujours pas
    OK. Qu'est-ce qui ne fonctionne toujours pas? Les messages d'erreur sont-ils différents, que disent-ils?
    Ce n'est qu'un bout du code qui est mis là, il faut le compléter avec ce que tu as dans ton script initial et qui fonctionne.

    Si tu veux le code complet :
    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
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    Set objShell = CreateObject("WScript.Shell")
    Set objFso=CreateObject("Scripting.FileSystemObject")
    For Each strIP in Split(objFso.OpenTextFile("Listeip.txt",1).ReadAll, ",")
    	strIP = Trim(strIP)
    	objShell.Run "C:\Windows\System32\telnet.exe " & strIP & " -f " & strIP & "-log.txt",,False 
    	WScript.Sleep 100
    	objShell.SendKeys "admin~" 
    	WScript.Sleep 100
    	objShell.SendKeys "1" 
    	WScript.Sleep 100
    	objShell.SendKeys "1~" 
    	WScript.Sleep 100
    	objShell.SendKeys "4" 
    	WScript.Sleep 100
    	objShell.SendKeys "2" 
    	WScript.Sleep 100
    	objShell.SendKeys "1~" 
    	WScript.Sleep 100
    	objShell.SendKeys "^z" 
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "4"
    	WScript.Sleep 100
    	objShell.SendKeys "3"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "4"
    	WScript.Sleep 100
    	objShell.SendKeys "3"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "2"
    	WScript.Sleep 100
    	objShell.SendKeys "7"
    	WScript.Sleep 100
    	objShell.SendKeys "3"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "2"
    	WScript.Sleep 100
    	objShell.SendKeys "1~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "4"
    	WScript.Sleep 100
    	objShell.SendKeys "1~"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "5"
    	WScript.Sleep 100
    	objShell.SendKeys "1~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "x"
    	WScript.Sleep 100
    	objShell.SendKeys "y~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    Next
    Bonne continuation

  16. #16
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    Citation Envoyé par pitchalov Voir le message
    OK. Qu'est-ce qui ne fonctionne toujours pas? Les messages d'erreur sont-ils différents, que disent-ils?
    Ce n'est qu'un bout du code qui est mis là, il faut le compléter avec ce que tu as dans ton script initial et qui fonctionne.

    Si tu veux le code complet :
    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
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    Set objShell = CreateObject("WScript.Shell")
    Set objFso=CreateObject("Scripting.FileSystemObject")
    For Each strIP in Split(objFso.OpenTextFile("Listeip.txt",1).ReadAll, ",")
    	strIP = Trim(strIP)
    	objShell.Run "C:\Windows\System32\telnet.exe " & strIP & " -f " & strIP & "-log.txt",,False 
    	WScript.Sleep 100
    	objShell.SendKeys "admin~" 
    	WScript.Sleep 100
    	objShell.SendKeys "1" 
    	WScript.Sleep 100
    	objShell.SendKeys "1~" 
    	WScript.Sleep 100
    	objShell.SendKeys "4" 
    	WScript.Sleep 100
    	objShell.SendKeys "2" 
    	WScript.Sleep 100
    	objShell.SendKeys "1~" 
    	WScript.Sleep 100
    	objShell.SendKeys "^z" 
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "4"
    	WScript.Sleep 100
    	objShell.SendKeys "3"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "4"
    	WScript.Sleep 100
    	objShell.SendKeys "3"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "1"
    	WScript.Sleep 100
    	objShell.SendKeys "2"
    	WScript.Sleep 100
    	objShell.SendKeys "7"
    	WScript.Sleep 100
    	objShell.SendKeys "3"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "2"
    	WScript.Sleep 100
    	objShell.SendKeys "1~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "4"
    	WScript.Sleep 100
    	objShell.SendKeys "1~"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "5"
    	WScript.Sleep 100
    	objShell.SendKeys "1~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    	WScript.Sleep 100
    	objShell.SendKeys "^z"
    	WScript.Sleep 100
    	objShell.SendKeys "x"
    	WScript.Sleep 100
    	objShell.SendKeys "y~"
    	WScript.Sleep 100
    	objShell.SendKeys "~"
    Next
    Bonne continuation
    Code s'exécute mais plusieurs fichiers sont vides alors qu'elles n'ont aucun problème, en plus de ca les fichiers texte s'ouvrent et ne se referment pas.
    parce que ce travail doit etre fait en arrière plan.
    Je me dis que pour etre sûr des informations que je pourrais récupérer, serait de faire par exemple un script batch qui pourra exécuter plusieurs scripts vbs.
    est ce que c'est possible ?

  17. #17
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut

    ça donne quoi si tu changes cette ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objShell.Run "C:\Windows\System32\telnet.exe " & strIP & " -f " & strIP & "-log.txt",,False
    par celle la :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objShell.Run "C:\Windows\System32\telnet.exe " & strIP & " -f " & strIP & "-log.txt",1,True

  18. #18
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Février 2012
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2012
    Messages : 17
    Par défaut
    Citation Envoyé par hackoofr Voir le message

    ça donne quoi si tu changes cette ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objShell.Run "C:\Windows\System32\telnet.exe " & strIP & " -f " & strIP & "-log.txt",,False
    par celle la :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objShell.Run "C:\Windows\System32\telnet.exe " & strIP & " -f " & strIP & "-log.txt",1,True
    j'ai du redémarrer ma machine, une boucle infini d'exécution

Discussions similaires

  1. Exporter Recordset vers fichier texte
    Par aures64 dans le forum VB 6 et antérieur
    Réponses: 1
    Dernier message: 11/11/2006, 03h25
  2. [XSLT] transformation xml vers fichier .text !
    Par kader78190 dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 03/11/2006, 13h45
  3. Export Table Acces vers fichier Texte
    Par ston dans le forum Access
    Réponses: 2
    Dernier message: 04/04/2006, 18h21
  4. SQL vers Fichier Texte
    Par annedjomo dans le forum MS SQL Server
    Réponses: 5
    Dernier message: 24/11/2005, 12h47
  5. Export vers fichier text
    Par Aurèl90 dans le forum Access
    Réponses: 10
    Dernier message: 26/10/2005, 11h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo