OVH Cloud OVH Cloud

Comment vérifier si SQL Serveur et IIS est installé sur le serveur?

2 réponses
Avatar
Jonathan
Bonjour,
j'aimerais savoir s'il y a un moyen en VB de vérifier si SQL Serveur et IIS
sont installés sur une machine, ce à partir de n'importe quel système
d'exploitation (2000 pro, 2000 Serveur, XP, NT4,....).

Merci en avance.

Jonathan

2 réponses

Avatar
Zoury
Salut Jonathan! :O)

AMHA,

pour SQL Server, tu pourrais vérifier si cette clé existe.. il y a même une
valeur CurrentVersion dans cette clé qui peut te founir la version installée
:
HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSSQLServerMSSQLServerCurrentVersion

pour IIS, tu pourrais testé cette clé
HKEY_CLASSES_ROOTIIS

ou encore testé l'existance de ce répertoire c:WINDOWSSystem32inetsrv
(peut varier en fonction de l'OS)

Ex :
'***
Option Explicit

Private Declare Function RegCloseKey _
Lib "advapi32.dll" _
( _
ByVal hKey As Long _
) As Long

Private Declare Function RegOpenKey _
Lib "advapi32.dll" _
Alias "RegOpenKeyA" _
( _
ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByRef phkResult As Long _
) As Long

Private Declare Function GetSystemDirectory _
Lib "kernel32" _
Alias "GetSystemDirectoryA" _
( _
ByVal lpBuffer As String, _
ByVal nSize As Long _
) As Long

Private Const HKEY_LOCAL_MACHINE As Long = &H80000002
Private Const HKEY_CURRENT_USER As Long = &H80000001
Private Const MAX_PATH As Long = 260&

Private Sub Form_Load()

' test pour SQL Server
Debug.Print RegistryKeyExists(HKEY_LOCAL_MACHINE,
"SOFTWAREMicrosoftMSSQLServerMSSQLServerCurrentVersion")

' tests pour IIS
Debug.Print RegistryKeyExists(HKEY_LOCAL_MACHINE,
"SOFTWAREMicrosoftMSSQLServerMSSQLServerCurrentVersion")
Debug.Print FolderExists(GetSystemPath & "inetsrv")

End Sub

Private Function RegistryKeyExists(ByRef hRootKey As Long, ByRef sPath As
String) As Boolean

Dim hKey As Long

Call RegOpenKey(hRootKey, sPath, hKey)
If (hKey > 0) Then
RegistryKeyExists = True
Call RegCloseKey(hKey)
End If

End Function

Private Function FolderExists(ByRef sFolder As String) As Boolean
On Error Resume Next
FolderExists = (GetAttr(sFolder) And vbDirectory) = vbDirectory
End Function

Private Function GetSystemPath() As String
GetSystemPath = Space$(MAX_PATH)
GetSystemPath = QualifyPath(Left$(GetSystemPath,
GetSystemDirectory(GetSystemPath, MAX_PATH)))
End Function

Private Function QualifyPath(ByRef sPath As String) As String
If (Right$(sPath, 1) = "") Then
QualifyPath = sPath
Else
QualifyPath = sPath & ""
End If
End Function
'***

--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
http://faq.vb.free.fr/?rubrique=0 - http://www.mvps.org/vbnet/
http://www.mentalis.org/agnet/apiguide.shtml - http://www.mztools.com/
"Jonathan" a écrit dans le message de
news:
Bonjour,
j'aimerais savoir s'il y a un moyen en VB de vérifier si SQL Serveur et


IIS
sont installés sur une machine, ce à partir de n'importe quel système
d'exploitation (2000 pro, 2000 Serveur, XP, NT4,....).

Merci en avance.

Jonathan


Avatar
Zoury
hmm.. 2 erreurs de copier/coller

remplace :
Private Const HKEY_CURRENT_USER As Long = &H80000001
par :
Private Const HKEY_CLASSES_ROOT As Long = &H80000000

remplace :
' test pour IIS
Debug.Print RegistryKeyExists(HKEY_LOCAL_MACHINE, _
"SOFTWAREMicrosoftMSSQLServerMSSQLServerCurrentVersion")
par :
' test pour IIS
Debug.Print RegistryKeyExists(HKEY_CLASSES_ROOT, "IIS")

--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
http://faq.vb.free.fr/?rubrique=0 - http://www.mvps.org/vbnet/
http://www.mentalis.org/agnet/apiguide.shtml - http://www.mztools.com/