Bonjour

Je souhaiterais récuperer des champs dans un fichier txt via vbs.
Mon probleme réside sur la récuperation d'un champs dans un fichier txt.

Cas 1:
Le fichier ConfigCfg.txt est structuré de la manière suivante :
nameserver;
namebdd;
nameinstance;

Je souhaiterai récupérer une information précise par ex: nameBdd
voici ce que j'ai fait
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
 
 
on error resume next
'Declaration de variables
Dim fso,strSourceFile,val,nb,prec,test,tab
Dim server,i,entier
strSourceFile="C:\chemin\ConfigCfg.txt"
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
 
set fso = createobject("Scripting.FileSystemObject")
If Not fso.FileExists(strSourceFile) Then
    wscript.echo "le fichier n'existe pas " 
Else
	wscript.echo "server :" & getVariable(1) 'retourne rien
End if 
 
Function getVariable(entier)
Set f = fso.OpenTextFile(strSourceFile, ForReading)
Do While not f.AtEndOfStream
   val = f.readline
   l = len(val)
   tabFile =left(val, l-1)
   getVariable = tabFile (entier)   
 
Loop 
 
set f = nothing 
End function
Cas 2 :
Pour le moment j'arrive à récupere l'infos si le fichier est structuré de la manière suivante.
Voici le texte :
nameserver;namebdd;nameinstance;


Voici le code réalisé
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
 
'Wscript
on error resume next
'Declaration de variables
Dim fso,strSourceFile,val,nb,prec,test
Dim server,i,entier
strSourceFile="c:\chemin\Config.txt"
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
 
set fso = createobject("Scripting.FileSystemObject")
If Not fso.FileExists(strSourceFile) Then
    wscript.echo "le fichier n'existe pas " 
Else
wscript.echo "server :" & getVariable(0) ' retourne la valeur nameserver
wscript.echo "Bdd    :" & getVariable(1)' retourne la valeur namebdd
wscript.echo "path   :" & getVariable(2)' retourne la valeur nameinstance
 
End if 
 
Function getVariable(entier)
 Set f = fso.OpenTextFile(strSourceFile, ForReading)
   	val=f.ReadLine	
	tabFile     = Split(val, ";")
	getVariable = tabFile(entier)	
 set f = nothing 
 
End function
Pourriez vous m'aidez ? Je ne vois pas comment je peux récuperer l'information lorsque le fichier structuré de la manière Cas 1:

Merci d'avance