Bonjour à tous,
Je vais vous exposer mon problème, je travaille sur du VBS.
Mon entreprise ou je suis possède des Scripts d'ouverture de session Windows codé en VBS.
Mon responsable m'a demandé de faire apparaitre une sorte de notification pour connaitre l'avancement
du script ainsi que quelques informations sur le PC client.
Niveau Popup j'utilise un popup IE, qui est très bien et qui rempli bien son rôle.
J'ai donc crée une Procédure Sub StartIE(strTache, intPercent)
strTache = Le Nom de l'étape du script
intPercent = Le nombre de pourcent de la barre de progression
Cela me permet d'avoir une barre de progression ou je peux vérifier quels fonctions mettent du temps à s'éxecuter,
et aussi pour l'optimisation du VBS plus tard, mais aussi pour savoir l'avancement du VBS.
- Mon Popup IE fonctionne très bien
- Les Informations du PC client ressortent bien
- Le pop IE s'ouvre à incrémentation de la valeur de "intPercent" à 0, et se ferme à < 100.
Mon problème est le suivant:
Je n'arrive pas à afficher la valeur de strTache dans mon PopupIE.
A savoir que la j'ai juste les informations de l'entreprise, et en dessous la barre
de progression.
Je vous met mon bout de code pour mieux comprendre:
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 Dim objIE, objDocument Set objDocument = Nothing Set objIE = Nothing ' *** Fonction pour attendre l'execution d'internet Explorer Function WaitForLoad(obj) Do While objIE.Busy Loop Do While obj.readyState=4 Loop wscript.sleep 300 End Function ' *** Fonction de la notification (popup ie + progress bar) Private Sub StartIE(strTache, intPercent) Dim objWSHShell Set objWSHShell = WScript.CreateObject("WScript.Shell") objWshShell.AppActivate("Microsoft Internet Explorer") Set objWSHShell = Nothing If objDocument Is Nothing Then If ((Cint(intPercent) >= 0) And (Cint(intPercent) <= 100)) Then Set objIE = CreateObject("InternetExplorer.Application") With objIE .Offline = True .AddressBar = False .Height = 300 .Width = 620 .MenuBar = False .StatusBar = False .Silent = True .ToolBar = False .Navigate "about:blank" End With WaitForLoad(objIE) 'On Error Resume Next Set objDocument = Nothing Do Until Not objDocument Is Nothing WScript.Sleep 100 Set objDocument = objIE.Document Loop objIE.Visible = True With objDocument .Open .Writeln "<html>" ' *** Début du code HTML .Writeln "<title>Ouverture de session en cours. Veuillez patienter, svp...</title> " .Writeln "<body>" .Writeln "<div>(informations de l'entreprise...)</div>" .Writeln "<div>" & Cstr(strTache) & "</div>" 'Afficher l'étape de progression 'Barre de progression .Writeln "<TABLE style='margin-left: 10px' width=500 border=1 frame=box><tr><td>" .Writeln "<TABLE id=status border=1 bgcolor=Navy>" .Writeln "<tr style='height: 10px;'><td></td></tr></TABLE></td></tr></TABLE></body>" .Writeln "</html>" ' *** Fin du code HTML .Close End With Else Exit Sub End If End If ' ***** Fermer la barre d'etat ***** If Not objDocument Is Nothing Then If ((Cint(intPercent) < 0) Or (Cint(intPercent) > 100)) Then objIE.Visible = False Set objDocument = Nothing objIE.Quit Set objIE = Nothing Exit Sub End If End If ' ***** Met a jour la barre d'etat ***** If Cint(intPercent) = 0 Then objDocument.all.status.width = "1%" objDocument.all.status.bgcolor = "midnightblue" Else objDocument.all.status.width = Cstr(Cint(intPercent)) & "%" objDocument.all.status.bgcolor = "midnightblue" End If End Sub '**** StartIE "Exécution 1", 0 wscript.sleep 1000 '**** StartIE "Exécution 2", 25 wscript.sleep 1000 '**** StartIE "Exécution 3", 50 wscript.sleep 1000 '**** StartIE "Exécution 4", 75 wscript.sleep 1000 '**** StartIE "Exécution 5", 100 wscript.sleep 1000 StartIE "", -1 '****
Merci d'avance aux personnes qui prendrons du temps pour lire mon problème, et y répondre.
Bonne journée à tous.
Q.
EDIT: Il manquait un "End With", & problème toujours non résolu.
Partager