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
| Option Explicit
Dim WS, shlApp, strCommand, strUser, strPassWord, strDomain, Nom_VPN, intReturn, strJob
' SYNTAXE : Rasdial Nom_VPN strUser strPassWord /DOMAIN:strDomain
' On doit renseigner le Nom_VPN
Nom_VPN = Chr(34) & Nom_VPN & Chr(34) ' pour éviter de méprendre l'espace dans l'entrée
strUser = "Nom_Utilisateur" ' à renseinger
strPassWord = "Mot_de_Passe" ' à renseinger
strDomain = "Nom_Domaine" ' à renseinger
strCommand = "Cmd.exe Rasdial.exe " & Nom_VPN & " " & strUser _
& " " & strUser & " " & strPassWord & " /DOMAIN:" & strDomain
Set WS = CreateObject("Wscript.Shell")
intReturn = WS.Run(strCommand, 0, True) 'La fenêtre n'est pas affichée, mais on attend la fin du processus
' On ferme l'objet WS, on n'en a plus besoin :
Set WS = Nothing
' Résultat de la requête :
If intReturn = 1 Then
intReturn = 0
strJob = "Succès de la connexion"
ElseIf intReturn >= 2 Then
intReturn = 1
strJob = "Une erreur est survenue"
Else
strJob = "Erreur inattendue"
End If
MsgBox strJob
' On passe à l'étape suivante (ouverture du dossier) si connexion OK :
If strJob = "Succès de la connexion" Then
Set shlApp = CreateObject("Shell.Application")
shlApp.Open "\\Srv-hyperv1\WS80010"
Else ' Sinon on quitte
MsgBox "Connexion non établie"
Wscript.Quit
End If
' A la fin, on ferme l'objet shlApp SI ON N'EN A PLUS BESOIN :
Set shlApp = Nothing |
Partager