Bonjour à tous,
je ne sais pas trop comment ni par où commencer...
Voilà mon souci, je me suis créé un petit script en VBS (utilisé en extension .hta) pour me connecter à différents serveurs de mon entreprise.
Script me demandant un Login et Mot de Passe.
Celui-ci fonctionne parfaitement mais 3 petits détails me dérangent car je n'arrive pas à les résoudre.
Le 1er est que l'on est obligé d'écrire son login en MAJUSCULE, il n'accepte pas les minuscules...
Le 2nd est lors de l'affichage de la fenêtre, je n'ai aucun focus de sélectionné. Je voudrais bien que le curseur soit dans la case Login en ayant sélectionner le mot "Login" afin que l'on puisse taper directement son login (je sais : trop de Login tue le login...).
Le 3ème est lors du passage à la case Mot de Passe par la tabulation. je voudrais comme pour la première case, sélectionner directement les caractères "******" afin que l'on puisse taper directement son Mot de Passe.
J'espère que cela est possible?
Je vous mets copie du code en espérant qu'une âme charitable aurait une solution à me proposer.
Bien à vous

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
214
215
216
 
<html>
	<head>
		<title>Connection de lecteurs r&eacute;seaux</title>
		<HTA:APPLICATION
			ID = "MapDrive"
			APPLICATIONNAME = "MapDrives.HTA"
			SINGLEINSTANCE = "yes"
			WINDOWSSTATE = "normal"
			VERSION = "1.0";
			SCROLL = "no"
			NAVIGABLE = "yes"
			MAXIMIZEBUTTON = "no";
			MINIMIZEBUTTON = "no";
			CONTEXTMENU = "no";
			SYSMENU = "yes"
			CAPTION = "yes"
			INNERBORDER = "no"; 
			SHOWINTASKBAR = "yes";
			ICON = "images/test.ico">
		>
		<link rel="stylesheet" type="text/css" href="style/style.css" />
	</head>
 
	<body>
		<script language="VBScript">
			Dim arrDrives(15,3)
			Dim strUser, strPw
			Dim booUserValid
 
			arrDrives(1,0) = "M:"
			arrDrives(1,1) = "\\IP\Dossier"
			arrDrives(1,2) = "Habilitations SMTP"
 
			arrDrives(2,0) = "N:"
			arrDrives(2,1) = "\\SERVEUR1\c$"
			arrDrives(2,2) = "C sur C51"
 
			arrDrives(3,0) = "O:"
			arrDrives(3,1) = "\\SERVEUR2\d$"
			arrDrives(3,2) = "D sur C51"
 
			arrDrives(4,0) = "P:"
			arrDrives(4,1) = "\\SERVEUR3\e$"
			arrDrives(4,2) = "E sur C51"
 
			arrDrives(5,0) = "Q:"
			arrDrives(5,1) = "\\SERVEUR4\f$"
			arrDrives(5,2) = "F sur C51"
 
			arrDrives(6,0) = "R:"
			arrDrives(6,1) = "\\SERVEUR5\k$"
			arrDrives(6,2) = "K sur C51"
 
			arrDrives(7,0) = "S:"
			arrDrives(7,1) = "\\IP\d$\Dossier"
			arrDrives(7,2) = "Dossier1"
 
			arrDrives(8,0) = "T:"
			arrDrives(8,1) = "\\SERVEUR6\d$\Dossier"
			arrDrives(8,2) = "Dossier2"
 
			arrDrives(9,0) = "U:"
			arrDrives(9,1) = "\\IP\\Dossier"
			arrDrives(9,2) = "Dossier3"
 
			arrDrives(10,0) = "V:"
			arrDrives(10,1) = "\\IP\\Dossier"
			arrDrives(10,2) = "Dossier4"
 
			arrDrives(11,0) = "W:"
			arrDrives(11,1) = "\\IP\\Dossier"
			arrDrives(11,2) = "\Dossier5"
 
			arrDrives(12,0) = "X:"
			arrDrives(12,1) = "\\IP\\Dossier"
			arrDrives(12,2) = "\Dossier6"
 
			arrDrives(13,0) = "Y:"
			arrDrives(13,1) = "\\IP\\Dossier"
			arrDrives(13,2) = "\Dossier7"
 
			arrDrives(14,0) = "Z:"
			arrDrives(14,1) = "\\IP\\Dossier"
			arrDrives(14,2) = "\Dossier8"
 
			strDomain = "COMMUN"
 
			Sub Window_Onload
				width = 450
				height = 300
				Self.ResizeTo width, height
				Self.MoveTo(screen.AvailWidth-width) / 2,(screen.AvailHeight-height) / 2
 
				blocLogin.innerHTML = "<span id='title'></span>" & _
				"<div id='msg1'>&nbsp;</div>" & _
				"<div id='divinput'><input tabindex='1' type='text' id='txtUserLog' name='inptUser' class='text' value='CP_ADM' />" & _
				"<input tabindex='2' type='password' id='txtUserPw' name='inptPw' class='text' value='******' /></div><br />" & _
				"<input tabindex='3' type='button' id='' class='buttonCNL' name='btnDisconnect' value='D&eacute;connecter' onClick='DisconnectDrives'>" & _
				"<input tabindex='4' type='button' id='' class='button' name='btnConnect' value='Connecter' onClick='RunScript()' />"
				txtUserLog.Focus
			End Sub
 
			Sub RunScript()
				On Error Resume Next
 
				strUser = txtUserLog.Value
				strPw = txtUserPw.Value
 
				If InStr(strUser, "_ADM") Then
					Call CheckAccess(strDomain, strUser, strPw)
 
					If booUserValid Then
						Call ConnectDrives()
						Self.Close()
					Else
						msg1.innerHTML = "<span class='red'>Identification echou&eacute;e !</span>"
					End If
				Else
					If strUser = "" And strPw = "" Then
						msg1.innerHTML = "<span class='red'>Champs vides interdits.</span>"
					ElseIf strUser = "" Then
						msg1.innerHTML = "<span class='red'>Nom d'utilisateur requis !</span>"
					ElseIf strPw = "" Then
						msg1.innerHTML = "<span class='red'>Mot de passe requis !</span>"
					Else
						msg1.innerHTML = "<span class='red'>Acc&egrave;s refus&eacute; ! (_ADM only)</span>"
					End If
				End If
			End Sub
 
			' ================================================================================================================
			' Connexion des lecteurs réseaux
			' ================================================================================================================
			Sub ConnectDrives()
				On Error Resume Next
 
				Set oNetwork = CreateObject("WScript.Network")
				Set oShell = CreateObject("Shell.Application")
 
				strUser = strDomain & "\" & UCase(strUser)
				Call ClearDrives
 
				For n = 0 To Ubound(arrDrives)
					Err.Clear
					oNetwork.MapNetworkDrive arrDrives(n,0), arrDrives(n,1), False, strUser, strPw
					If Err.Number = 0 Then
						oShell.NameSpace(arrDrives(n,0)).Self.Name = arrDrives(n,2)
					End If
				Next
 
				Set oShell = Nothing
				Set oNetwork = Nothing
			End Sub
 
			Sub DisconnectDrives()
				Call ClearDrives
				Set oShell = Nothing
				Set oNetwork = Nothing
				Self.Close()
			End Sub
 
			' ================================================================================================================
			' Déconnexion des lecteurs réseaux existants
			' ================================================================================================================
			Sub ClearDrives()
				On Error Resume Next
 
				Set oNetwork = CreateObject("WScript.Network")
 
				Set AllDrives = oNetwork.EnumNetworkDrives
				For n = 0 To Ubound(arrDrives)
					For i = 0 To AllDrives.Count - 1 Step 2
						If AllDrives.Item(i) = arrDrives(n,0) Then AlreadyConnected = True
					Next
					If AlreadyConnected = True Then
						oNetwork.RemoveNetworkDrive arrDrives(n,0), True, True
					End If
				Next
			End Sub
 
			' ================================================================================================================
			' Vérification du login
			' ================================================================================================================
			Sub CheckAccess(strDomain, strUserID, strUserPWD)
				On Error Resume Next
 
				Const ADS_SECURE_AUTHENTICATION = &h0001
				Const ADS_CHASE_REFERRALS_ALWAYS = &H60
 
				Dim oDSO, oUser, strPath
 
				strPath = "LDAP://" & strDomain & "/OU=Users,DC=" & strDomain
 
				Set oDSO = GetObject("LDAP:")
				Set oUser = oDSO.OpenDSObject (strPath, strUserID, strUserPWD, ADS_SECURE_AUTHENTICATION Or ADS_CHASE_REFERRALS_ALWAYS)
 
				If Err.Number <> 0 Then
					booUserValid = False
				Else
					booUserValid = True
				End If
 
				Err.Clear
 
				On Error Goto 0
 
				Set oDSO = Nothing
				Set oUser = Nothing
			End Sub
		</script>
		<div id="blocs">
			<div id="blocLogin"></div>
		</div>
	</body>
</html>