Bonjour,

Je suis plus que novice en matière de programmation, cependant j'ai la chance d'arriver à "déchiffrer" du code.
Cependant, je comprends pas du tout ce qui suit.
J'ai un .hta de configuration pour un logiciel qui s'appelle Jchat.
Or dans le code, j'ai une FSO pour créer un répertoire alimenté par une variable après un texte d'existence.
Cependant, j'ai une erreur de script avec le message suivant :
Ligne : 59
Caractère 9
Erreur : Chemin d'accès introuvable
Code 0
URL : xxx

Du coup j'ai inhibé ce passage et j'ai donc relancer, et la même type d'erreur mais cette fois avec la FSO opentextfile de la ligne99 ...

J'ai beau vérifier avec mes très maigres connaissances, je comprends pas...
Je précise que je travaille sur un PC en Win 7 Pro x64. Peut etre que vu la date du script le langage a évolué et sur un Win 7 les déclarations ne sont plus bonnes.
J'ai tenté de vérifier dans la faq, mais je vois pas... les déclarations ont l'air bonne.
Celà fait plusieurs jours que je cherche, je comprends pas, et le pire c'est que ca doit etre tout bête.
Du coup, j'utilise la solution de facilité et demande un coup de main.

Ce programme a fonctionné et il me ferait gagner énormément de temps.


Je ne mets ici que le code VB, le code HTML du HTA lui fonctionne.

Je vous remercie par avance.

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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
 
   <SCRIPT LANGUAGE="VBScript">
 
'=========== Constantes =====================================
 
Const constBarreProgressMax = 350
Const constServerFQDN = "jchat.XX.fr"
Const constServerName = "jchat.XX.fr"
Const constJChatClientVersion = "1.3.4"
 
'=========== Objets Globaux =================================
 
Set Shell = CreateObject("WScript.Shell")
Set FSO   = CreateObject("Scripting.FileSystemObject")
Set NET   = CreateObject("WScript.Network")
 
'=========== Constantes conditionnelles =====================
 
constProgDir = Shell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
constProfil = Shell.ExpandEnvironmentStrings("D:\USERS\%USERNAME%")
constJChatProfil = constProfil & "\jchat"
constJChatEXE = constProgDir & "\JChatClient\JChatClient.exe"
constProfilCommun = constJChatProfil & "\chat_client.cfg"
constProfilServeur = constJChatProfil & "\MyPlaces.xml"
 
'=========== Fin des éléments communs =======================
 
ResizeTo 800,600
 
Sub Window_onLoad
    EffacerInformation
End Sub
 
Sub Script_JChat_OnClick
 
    ' Efface la div contenant les information des action réalisé par le script
    EffacerInformation
 
    ' === ETAPE 1 ===
    AfficherInformation "Détection du client JChat.", "Add"
 
    If Not FSO.FileExists(constJChatEXE) Then
        AfficherInformation "JChat n'est pas installé.", "Err"
        Msgbox "Le client JChat n'a pas été détecté sur votre machine." & vbCrLf & "Veuillez demander l'installation de ce logiciel à votre administrateur." & vbCrLf & "Echec de la procédure.", vbCritical
        Exit Sub
    End If
 
    ' === ETAPE 2 ===
    AfficherInformation "Vérification de l'état de JChat.", "Add"
 
    If VerifProcess("JChatClient.exe") Then
        AfficherInformation "Impossible de poursuivre, le client JChat est ouvert.", "Err"
        Msgbox "Veuillez fermer JChat avant de pouvoir procéder à la mise à jour." & vbCrLf & "Echec de la procédure.", vbCritical
    Exit Sub
    End If
 
    ' === ETAPE 3 ===
    If Not FSO.FolderExists(constJChatProfil) Then
        AfficherInformation "Creation d'un profil vierge.", "Add"
        FSO.CreateFolder constJChatProfil
    End If
 
    ' === ETAPE 4 ===
    AfficherInformation "Vérification du nom d'utilisateur", "Add"
    Set o = document.getElementById("username")
    If o.value = "" Then
        AfficherInformation "Vous n'avez pas saisi de nom d'utilisateur&nbsp;!", "Err"
        Exit Sub
    Else
        o.value = Trim(o.value)
        AfficherInformation "Création d'un profil pour l'utilisateur <b>" & o.value & "</b>", "Add"
    End If
 
    ' === ETAPE 5 ===
    AfficherInformation "Configuration du profil spécifique", "Add"
    ProfilSpecifique
 
    ' === ETAPE 6 ===
    AfficherInformation "Configuration du profil commun", "Add"
    ProfilCommun
 
    ' === ETAPE 7 ===
    AfficherInformation "Lien au serveur", "Add"
    ProfilServeur
 
    AfficherInformation "Configuration terminée.", "Add"
    AfficherMessageFin
 
  '  Shell.Exec constJChatEXE
End Sub
 
' ================================================
' Fonctions de décharge de la procédure principale
' ================================================
 
Sub ProfilSpecifique
    Set o = document.getElementById("username")
    profil = constJChatProfil & "\" & o.value & ".cfg"
 
    Set f = FSO.OpenTextFile(profil, 2, True)
 
    f.Write "jchat.apps.chatclient.login="
    f.WriteLine o.value
    f.WriteLine "jchat.apps.chatclient.ssoprincipal="
    f.WriteLine "jchat.apps.chatclient.jabberHost=" & constServerFQDN
    f.Write "jchat.apps.chatclient.nick="
    f.WriteLine o.value
    f.WriteLine "jchat.apps.chatclient.xmppServiceName=" & constServerFQDN
    f.Close
End Sub
 
Sub ProfilCommun
    Set f = FSO.OpenTextFile(constProfilCommun, 2, True)
    Set o = document.getElementById("username")
 
    loggingpath = constJChatProfil & "\Conversations"
    loggingpath = Replace(loggingpath, "\", "\\")
    loggingpath = Replace(loggingpath, ":", "\:")
 
    f.Write "jchat.apps.chatclient.loggingpath="
    f.WriteLine loggingpath
    f.Write "jchat.apps.chatclient.store_last_selected_profile="
    f.WriteLine o.value
    f.WriteLine "jchat.apps.chatclient.datetimeformat=dd-MMM-yyyy HH\:mm\:ss"
    f.Write "jchat.apps.chatclient.version="
    f.WriteLine constJChatClientVersion
    f.WriteLine "jchat.apps.chatclient.timezone="
    f.Close
End Sub
 
Sub ProfilServeur
    Set f = FSO.OpenTextFile(constProfilServeur, 2, True)
    f.WriteLine "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>"
    f.WriteLine "<jChatMyServerData>"
    f.Write "    <servername>"
    f.Write constServerName
    f.WriteLine "</servername>"
    f.WriteLine "</jChatMyServerData>"
    f.Close
End Sub
 
' =====================
' Fonctions utilitaires
' =====================
 
Function VerifProcess(objProcess)
    For Each Process In GetObject("winmgmts:").InstancesOf("Win32_process")
        If UCase(Process.Name) = UCase(objProcess) Then
            VerifProcess = True
            Exit Function
        End If
    Next
    VerifProcess = false
End Function
 
Sub CreerRacourciBureau(Cible, NomRaccourci)
    Dim DesktopPath, URL
    DesktopPath = Shell.SpecialFolders("Desktop")
    Set URL = Shell.CreateShortcut(DesktopPath & "\" & NomRaccourci & ".lnk")
    URL.TargetPath = Cible
    URL.Save
    Set URL = Nothing
End Sub
 
Sub AfficherInformation(Information, Progression)
    ' Gestion du message
    Set o = document.getElementById("Span_information_1")
    o.innerhtml =  o.innerhtml & "</br>" & Information
    o.scrollTop = o.scrollHeight
    Set o = Nothing
 
    ' Gestion de la progression (ProgressBar)
    Select Case Progression
    Case "Add"
        tb1.width = tb1.width + 20
    Case "Err"
        tb1.width = constBarreProgressMax
        tb1.bgColor = "red"
    End Select
 
    If Int(tb1.width) > Int(constBarreProgressMax) Then
        tb1.width = constBarreProgressMax
    End If
End Sub
 
Sub EffacerInformation
    ' Gestion du message
    Set o = document.getElementById("Span_information_1")
    o.innerhtml =  ""
    Set o = Nothing
 
    ' Gestion de la progression (ProgressBar)
    tb1.width = 1
    tb1.bgColor = "green"
End Sub
 
Sub CopierFichier (FichierSource, FichierDestination)
    Const OverwriteExisting = True
    FSO.CopyFile FichierSource, FichierDestination, OverwriteExisting
End Sub
 
Sub AfficherMessageFin
    tb1.width = constBarreProgressMax
 
    Set o = document.getElementById("Span_information_1")
    o.innerhtml =  o.innerhtml & "<br> <h3> Fin de procédure.Vous pouvez fermer la fenêtre.</h3>"
    Set o = document.getElementById("footer")
    o.innerhtml = "Date de révision : 16/06/2014, Version: 1.1-BSS, Concepteur : SM BE ; Dernière révision : SM B"
    o.scrollTop = o.scrollHeight
    Set o = Nothing
End Sub
 
    </SCRIPT>