Précédent   Forum du club des développeurs et IT Pro > Autres langages > Général Visual Basic 6 et VBScript > VBScript
VBScript Le forum d'entraide sur VBScript. Avant de poster -> La FAQ VBScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 19/02/2013, 17h25   #1
ponpon17430
Futur Membre du Club
 
Inscription : août 2006
Messages : 111
Détails du profil
Informations forums :
Inscription : août 2006
Messages : 111
Points : 19
Points : 19
Par défaut HTA et ajout innerhtml

Bonjour,

J'ai un script qui me permet de lister des fichiers sur mon profil utilisateur en fonction de l'extension.

ce que j'aimerai faire est d'avoir une checkbox devant chaque chemin et ensuite en fonction de ce qui est coché, copier le fichier selectionné.

Actuellement, j'affiche le chemin des fichiers mais tout est à la suite, je n'arrive pas a faire de retour à la ligne.
J'ai essayé d'ajouter /n ou <TR> mais ca ne fonctionne pas

Merci d'avance pour votre aide.

voici la fonction qui liste des pst :

Code :
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
 
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
 
start_folder = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
ext = Array("pst")
 
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set folder = oFSO.GetFolder(start_folder)
 
 
Sub ListPST(folder, ext)
 
    For Each objFile In folder.Files
 
If (UCase(ext(0)) = UCase(oFSO.GetExtensionName(objFile.Name))) Then
 
	    strFileName = objFile.Name
        strFilePath = objFile.ParentFolder
		strhtml = strhtml & strFileName
		listingPST.innerHTML =   listingPST.innerHTML & strFilePath & "\" & strFileName            
        End If
    Next
    For Each fldr In folder.subfolders
        ListPST fldr, ext
    Next
 
End Sub
 
ListPST folder, ext
ponpon17430 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/02/2013, 17h39   #2
ProgElecT
Rédacteur/Modérateur
 
Avatar de ProgElecT
 
Homme Francis MILLET
Inscription : décembre 2004
Messages : 3 199
Détails du profil
Informations personnelles :
Nom : Homme Francis MILLET
Âge : 57
Localisation : France, Haute Savoie (Rhône Alpes)

Informations professionnelles :
Secteur : Communication - Médias

Informations forums :
Inscription : décembre 2004
Messages : 3 199
Points : 5 109
Points : 5 109
Envoyer un message via MSN à ProgElecT
Salut
Code :
listingPST.innerHTML =   listingPST.innerHTML & strFilePath & "\" & strFileName & "<BR>"
peut être
ProgElecT est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/02/2013, 09h38   #3
ponpon17430
Futur Membre du Club
 
Inscription : août 2006
Messages : 111
Détails du profil
Informations forums :
Inscription : août 2006
Messages : 111
Points : 19
Points : 19
Merci, ca fonctionne ! j'avais oublié de tester la balise BR
Bon maintenant il y a plus qu'a créé une checkbox pour chaque pst trouvé.

Edit c'est bon j'ai les checkbox mais là je me trouve coincé pour copié le fichier selectionné
ponpon17430 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/02/2013, 09h52   #4
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 636
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 636
Points : 3 706
Points : 3 706

Postez votre code HTA modifié
hackoofr est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/02/2013, 10h06   #5
ponpon17430
Futur Membre du Club
 
Inscription : août 2006
Messages : 111
Détails du profil
Informations forums :
Inscription : août 2006
Messages : 111
Points : 19
Points : 19
Et voila

Code :
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
 
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
 
start_folder = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
ext = Array("pst")
 
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set folder = oFSO.GetFolder(start_folder)
 
count = ""
Sub ListPST(folder, ext)
 
    For Each objFile In folder.Files
 
If (UCase(ext(0)) = UCase(oFSO.GetExtensionName(objFile.Name))) Then
	count = count + "1"
	    strFileName = objFile.Name
        strFilePath = objFile.ParentFolder
 
		listingPST.innerHTML = listingPST.innerHTML & ("<input type='checkbox' value='" & count & "' name='" & count & "' onclick=''></input>") & " " & strFileName & "<BR>"
 
		'listingPST.innerHTML =  listingPST.innerHTML & strFileName & "<BR>"
           msgbox count
        End If
    Next
    For Each fldr In folder.subfolders
        ListPST fldr, ext
    Next
 
End Sub
à la place de count j'avais mis la variable strFileName mais bon comment récupérer la valeur de ma checkbox par la suite
ponpon17430 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/02/2013, 10h51   #6
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 636
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 636
Points : 3 706
Points : 3 706
Je veux dire tout le contenu du HTA et non pas le vbscript seulement comme dans cet exemple Recherche & Sauvegarde des fichiers par leurs Extensions
Pour la CheckBox pour le moment aucune idée , mais vous pouvez explorer le dossier qui contient le fichier en question et le copier
hackoofr est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/02/2013, 11h31   #7
ponpon17430
Futur Membre du Club
 
Inscription : août 2006
Messages : 111
Détails du profil
Informations forums :
Inscription : août 2006
Messages : 111
Points : 19
Points : 19
Actuellement je passe par robocopy qui recherche et copie les PST.

En fait l'évolution que j'aimerai faire, c'est, de lister les PST et ensuite je choisis quel fichier sauver sans à avoir à explorer le répertoire.

Voici le code en entier
Code :
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
 
<html>
<head>
<title>Backup utility</title>
</head>
 
<body>
 
Select backup option :
<br>
<input type="checkbox" ID="PST" name="PST"> : Backup all PST files present in your user profile.
<br>
<div id = "listingPST" name="listingPST"></div>
<div id = "ValidePST" name="ValidePST"></div>
<div id = "Encours" name="Encours"></div>
<br>
<input type="button" id="BTvalider" name="valider" value="Start" onclick="backup()">
<input type="button" Id="BTFermer" name="BTFermer" value="Close"  OnClick="fermer()">
<br>
 
</body>
</html>
 
<script type="text/javascript"> 
function fermer() 
{ 
self.close(); 
}  
</script>
<SCRIPT LANGUAGE="VBScript">
ResizeTo 670,460
 
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = CreateObject("WScript.Shell")
 
 
Sub VerifProcessPST(objProcess)
 
For Each Process In GetObject("winmgmts:").InstancesOf("Win32_process")
     If UCase(Process.Name) = UCase(objProcess) Then
        msgbox "Backup canceled : " & Process.Name & " is active..."& Chr(13) &"Close Outlook and launch again utility"
        Exit Sub
     End If
Next
 
ListPST folder, ext
 
End Sub
 
 
'======================================================================
' TEST  list PST
'======================================================================
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
 
start_folder = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
ext = Array("pst")
 
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set folder = oFSO.GetFolder(start_folder)
 
Sub ListPST(folder, ext)
 
	Encours.innerhtml = " Select PST to save : "
    For Each objFile In folder.Files
 
If (UCase(ext(0)) = UCase(oFSO.GetExtensionName(objFile.Name))) Then
 
	    strFileName = objFile.Name
        strFilePath = objFile.ParentFolder
 
		listingPST.innerHTML = listingPST.innerHTML & ("<input type='checkbox' value='" & count & "' name='" & count & "' onclick=''></input>") & " " & strFileName & "<BR>"
 
		'listingPST.innerHTML =  listingPST.innerHTML & strFileName & "<BR>"
           msgbox count
        End If
    Next
    For Each fldr In folder.subfolders
        ListPST fldr, ext
    Next
 
 
End Sub
 
' FIN TEST
'======================================================================
 
 
'==================================================================================================================
'Fonction après avoir appuyé sur le bouton continuer.
'Vérifie si un choix est coché et execute le backup de l'option sélectionné.
'==================================================================================================================
 
Sub backup
	If objGroup.IsMember(objUser.ADsPath) Then 
		if (PST.Checked = false) then
 
			Msgbox "Please select one option before continuing"
 
			else
				reponse = msgbox ("The backup can take few minutes, do you want continue ?", vbYesNo)
				If reponse = vbYes then
 
					If PST.Checked Then
					VerifProcessPST("outlook.exe")
					End if
 
					BTvalider.disabled = False
					BTFermer.disabled = False
				else
					msgbox " Backup finish"
					fermer()
				End If
		End if
	Else
	Msgbox "Your are not allowed to use this utility."
	End if
End Sub
 
</SCRIPT>
ponpon17430 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 02h14.


 
 
 
 
Partenaires

Hébergement Web