HTA et texte dynamique

robin42p Messages postés 19 Date d'inscription dimanche 26 janvier 2003 Statut Membre Dernière intervention 19 décembre 2008 - 19 déc. 2008 à 01:10
robin42p Messages postés 19 Date d'inscription dimanche 26 janvier 2003 Statut Membre Dernière intervention 19 décembre 2008 - 19 déc. 2008 à 08:17
Bonjour,

Je débute dans l'utilisation d'une interface HTA + VBS.

Je souhaite afficher à la volée différentes infos liées à la config de l'ordinateur en cours (processeur, mémoire, services, processus, etc...)

Mon problème se situe au niveau de l'affichage dynamique, qui ne l'est pas pour le moment ...

Le script est défini dans le "head" et celui-ci est chargé de cette façon

Voici la fonction qui rajoute une ligne dans le div principal :

Function AddL(strField, strValue)
    Set o = document.getElementById("log")
    o.innerHTML = o.innerHTML & "
" & strField & " : " & strValue & "
"
End Function

Actuellement le résultat de ma div s'affiche uniquement une fois que le script VBS est complètement terminé et ce n'est pas très pratique (le script peut durer plusieurs dizaines de secondes)

Avez-vous une solution svp ?

Par avance merci

5 réponses

PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
19 déc. 2008 à 01:26
salut,

de ton utilisation tu aurais plus de chances d'avoir une réponse en ASP, plutôt que directement VBS...

<hr size="2" width="100%" />
Prenez un instant pour répondre à [sujet-SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp 
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
19 déc. 2008 à 05:55
c'est un peu étrange, ce que tu generes.
tu vas te retrouver avec n objets (div) avec le même id, ce qui n'est pas légal

pas de guillemets autour des valeur des attributs... c'est maladroit (incorrect en XHTML strict)

le AddL est bien appelé, comme il faut dans le corps de ta fonction Go ?
0
robin42p Messages postés 19 Date d'inscription dimanche 26 janvier 2003 Statut Membre Dernière intervention 19 décembre 2008
19 déc. 2008 à 08:07
Pour l'histoire du même id, tu as raison Renfield, mais ce n'est qu'un test qui n'est pas optimisé, du coup il ne respecte pas les standards pour le moment.

Voici une petite partie de code (je l'ai simplifié mais ça fait pareil)

<html>
<head>
<title>test</title>
<HTA:APPLICATION
    ID="objTest"
    APPLICATIONNAME="test"
    SINGLEINSTANCE="yes"
    MAXIMIZEBUTTON="no"
    MINIMIZEBUTTON="no"
    CONTEXTMENU="no"
    BORDERSTYLE="normal"
    BORDER="thin"
    SHOWINTASKBAR="yes"
    ICON="favicon.ico"
    >

<SCRIPT LANGUAGE="VBScript">
Function Go()
window.resizeTo 530,360

Dim strComputer
Dim objWMI
Dim col, obj

strComputer = "."
Set objWMI = GetObject("winmgmts:\" & strComputer & "\root\cimv2")

Set col = objWMI.InstancesOf("Win32_OperatingSystem")
For Each obj In col
    AddL "Nom d'hôte" , obj.CSName
    AddL "Systeme d'exploitation" , obj.Caption
    AddL "Version" , obj.Version
    AddL "Nom du propriétaire" , obj.RegisteredUser
    AddL "Dossier Windows" , obj.WindowsDirectory
    AddL "Dossier Systeme" , obj.SystemDirectory
    AddL "Mémoire Physique" , round(obj.TotalVisibleMemorySize / 1024) & " MB"
    AddL "Pagination Max" , round(obj.TotalVirtualMemorySize / 1024) & " MB"
Next

Set col = objWMI.ExecQuery("Select * from Win32_Processor")
For Each obj In col
    AddL "Processeur", obj.Name
    AddL "Fréquence CPU max", obj.MaxClockSpeed & "MHz"
Next

Set obj = objWMI.InstancesOf("Win32_Service")
For each col In obj
    AddL col.Caption, col.Started
Next

Set obj = Nothing
Set col = Nothing
Set objWMI = Nothing

End Function

Function AddL(strField, strValue)
    Set o = document.getElementById("log")
    o.innerHTML = o.innerHTML & strField & " : " & strValue & "
"
End Function

</SCRIPT>
</head>

       

</html>
0
robin42p Messages postés 19 Date d'inscription dimanche 26 janvier 2003 Statut Membre Dernière intervention 19 décembre 2008
19 déc. 2008 à 08:12
Décidément...
Set obj = objWMI.InstancesOf("Win32_Service")
For each obj In col
    AddL obj.Caption, obj.Started
Next

Désolé pour ce triple message
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
robin42p Messages postés 19 Date d'inscription dimanche 26 janvier 2003 Statut Membre Dernière intervention 19 décembre 2008
19 déc. 2008 à 08:17
le code corrigé est donc celui-ci

<title>test</title>
<HTA:APPLICATION
    ID="objTest"
    APPLICATIONNAME="test"
    SINGLEINSTANCE="yes"
    MAXIMIZEBUTTON="no"
    MINIMIZEBUTTON="no"
    CONTEXTMENU="no"
    BORDERSTYLE="normal"
    BORDER="thin"
    SHOWINTASKBAR="yes"
    ICON="favicon.ico"
    >

<SCRIPT LANGUAGE="VBScript">
Function Go()
window.resizeTo 530,360

Dim strComputer
Dim objWMI
Dim col, obj

strComputer = "."
Set objWMI = GetObject("winmgmts:\" & strComputer & "\root\cimv2")

Set col = objWMI.InstancesOf("Win32_OperatingSystem")
For Each obj In col
    AddL "Nom d'hôte" , obj.CSName
    AddL "Systeme d'exploitation" , obj.Caption
    AddL "Version" , obj.Version
    AddL "Nom du propriétaire" , obj.RegisteredUser
    AddL "Dossier Windows" , obj.WindowsDirectory
    AddL "Dossier Systeme" , obj.SystemDirectory
    AddL "Mémoire Physique" , round(obj.TotalVisibleMemorySize / 1024) & " MB"
    AddL "Pagination Max" , round(obj.TotalVirtualMemorySize / 1024) & " MB"
Next

Set col = objWMI.ExecQuery("Select * from Win32_Processor")
For Each obj In col
    AddL "Processeur", obj.Name
    AddL "Fréquence CPU max", obj.MaxClockSpeed & "MHz"
Next

Set col = objWMI.InstancesOf("Win32_Service")
For each obj In col
    AddL obj.Caption, obj.Started
Next

Set obj = Nothing
Set col = Nothing
Set objWMI = Nothing

End Function

Function AddL(strField, strValue)
    Set o = document.getElementById("log")
    o.innerHTML = o.innerHTML & strField & " : " & strValue & "
"
End Function

</SCRIPT>
</head>

       

</html>

Voilà, ce matin ce n'est pas le forme lol !
0
Rejoignez-nous