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 :

Problème HTA + vbscript


Sujet :

VBScript

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Technicien Help Desk
    Inscrit en
    Mai 2017
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : Canada

    Informations professionnelles :
    Activité : Technicien Help Desk

    Informations forums :
    Inscription : Mai 2017
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Problème HTA + vbscript
    j'ai un problème avec mon HTA je suis incapable de faire fonctionner mon vbs.. Le script roule très bien tout seul mais un coup dans le HTA ca me donne un erreur sur la ligne 41 soit = Function Ping(strComputer)

    je ne trouve pas la solution pouvez vous m'aider ?
    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
    <html> 
    <head> 
     
    <title>Ping Utility</title> 
     
    <hta:application id="Accespointtest" applicationname="acces point link test" border="thin" caption="yes" contextmenu="no" maximizebutton="no" 
    navigable="no" scroll="no" selection="yes" showintaskbar="yes" singleinstance="yes" sysmenu="yes" windowstate="normal"> 
     
    </head> 
     
     
    body { background-color:#173b71; color:black; font-family:arial; font-size:12pt; border:0px; padding:0px; margin:0px; } 
    div{ background-color:#173b71; color:white; font-family:tahoma; font-size:8pt; } 
    div.msg { background-color:#a1c6eb; border:3px double white; border-style:thin; color:black; font-family:tahoma; font-size:8.5pt; 
              font-weight:bold; position:relative; } 
    div.title{ background-color:#173b71; color:white; font-family:san-sarif; font-size:10pt; font-weight:bold; } 
     
     
    <script language="VBScript"> 
    Sub Window_Onload 
       window.resizeTo 200,150 
    End Sub 
     
     
    Sub pingfromlist()
     
     strList = "c:\list.txt"
    strLog = "c:\log.txt"
     
    Set objfso = CreateObject("scripting.filesystemobject")
    Set objlist = objfso.OpenTextFile(strList,1)
    Set objlog = objfso.CreateTextFile(strLog,True)
     
    Do Until objlist.AtEndOfStream
    strComputer = objlist.ReadLine
    objlog.WriteLine Ping(strComputer) 
    Loop
     
     
     
    Function Ping(strComputer)
    Set objShell = CreateObject("WScript.Shell")
    Set objScriptExec = objShell.Exec( _
        "ping -n 2 " & strComputer)
    strPingResults = LCase(objScriptExec.StdOut.ReadAll)
    If InStr(strPingResults, "ms") Then
        If InStr(strPingResults, "la" ) Then
            Ping = "did not respond to ping."
        Else
            Ping = strComputer & " responded to ping."
        End If 
    Else
        Ping = strComputer & " did not respond to ping."
    End If
    End Function
    End Sub 
    </script> 
     
    <body onkeypress="DoCheckEnterKey"> 
    <div class="title" style="position:absolute; left:45px; top:5px;">execute a ping test on all access point</div> 
     
    <div style="position:absolute; left:5px; top:40px; width:85px; height:35px;"><b>check logfile in c:</b></div> 
    <input class="action_button" type="button" value="Ping" name="PingButton" 
     onClick="pingfromlist" tabindex="2" style="position:absolute;left:225px; top:45px;"> 
     
    </body> 
    </html>

  2. #2
    Modérateur
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 077
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 077
    Points : 17 172
    Points
    17 172
    Par défaut
    Salut, bienvenue sur DVP

    Une première correction
    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
    <html> 
    <head> 
     
    <title> Ping Utility </title> 
     
    <hta:application id="Accespointtest" applicationname="acces point link test" border="thin" caption="yes" contextmenu="no" maximizebutton="no" 
    navigable="no" scroll="no" selection="yes" showintaskbar="yes" singleinstance="yes" sysmenu="yes" windowstate="normal"> 
     
    </head> 
     
    <style> 
    body { background-color:#173b71; color:black; font-family:arial; font-size:12pt; border:0px; padding:0px; margin:0px; } 
    div{ background-color:#173b71; color:white; font-family:tahoma; font-size:8pt; } 
    div.msg { background-color:#a1c6eb; border:3px double white; border-style:thin; color:black; font-family:tahoma; font-size:8.5pt; 
              font-weight:bold; position:relative; } 
    div.title{ background-color:#173b71; color:white; font-family:san-sarif; font-size:10pt; font-weight:bold; } 
    </style> 
     
    <script language="VBScript"> 
    Sub Window_Onload 
       window.resizeTo 200,150 
    End Sub 
    '*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*
    Sub pingfromlist()
     
    strList = "c:\list.txt"
    strLog = "c:\log.txt"
     
    Set objfso = CreateObject("scripting.filesystemobject")
    Set objlist = objfso.OpenTextFile(strList,1)
    Set objlog = objfso.CreateTextFile(strLog,True)
     
    Do Until objlist.AtEndOfStream
    strComputer = objlist.ReadLine
    objlog.WriteLine Ping(strComputer) 
    Loop
    End Sub 
    '*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*
    Function Ping(strComputer)
    Set objShell = CreateObject("WScript.Shell")
    Set objScriptExec = objShell.Exec( _
        "ping -n 2 " & strComputer)
    strPingResults = LCase(objScriptExec.StdOut.ReadAll)
    If InStr(strPingResults, "ms") Then
        If InStr(strPingResults, "la" ) Then
            Ping = "did not respond to ping."
        Else
            Ping = strComputer & " responded to ping."
        End If 
    Else
        Ping = strComputer & " did not respond to ping."
    End If
    End Function
    '*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*
    </script> 
     
    <body onkeypress="DoCheckEnterKey"> 
    <div class="title" style="position:absolute; left:45px; top:5px;">execute a ping test on all access point</div> 
     
    <div style="position:absolute; left:5px; top:40px; width:85px; height:35px;"><b>check logfile in c:</b></div> 
    <input class="action_button" type="button" value="Ping" name="PingButton" 
     onClick="pingfromlist" tabindex="2" style="position:absolute;left:225px; top:45px;"> 
     
    </body> 
    </html>
    <body onkeypress="DoCheckEnterKey">la fonction DoCheckEnterKey ou sub n'existe pas dans ton code.
    pour le CSS:
    la classe action_button n'existe pas dans ton code.
    la classe div.msg n'existe pas dans ton code.
    la classe action_button n'existe pas dans ton code.
    Impossible d'essayer ton code du fait que tu charge 2 fichiers externes, strList = "c:\list.txt" et strLog = "c:\log.txt"
    Soyez sympa, pensez -y
    Balises[CODE]...[/CODE]
    Balises[CODE=NomDuLangage]...[/CODE] quand vous mettez du code d'un autre langage que celui du forum ou vous postez.
    Balises[C]...[/C] code intégré dans une phrase.
    Balises[C=NomDuLangage]...[/C] code intégré dans une phrase quand vous mettez du code d'un autre langage que celui du forum ou vous postez.
    Le bouton en fin de discussion, quand vous avez obtenu l'aide attendue.
    ......... et pourquoi pas, pour remercier, un pour celui/ceux qui vous ont dépannés.
    👉 → → Ma page perso sur DVP ← ← 👈

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