Friday, August 22, 2008

Ikusa Otome Valkyrie Watch

is installed on a computer

I'm trying to create a simple script on Asp.net, emulating the simplicity of WordPress, to install a web application on any computer.

As I'm using SQL Server as database, I need before installing the application schema in SQL server, verify that SQL Server is installed on your computer.

Windows 2000 and later (XP, 2003, etc.) brings in the WMI core which allows the review, and action, about windows services.

A very useful tool for WMI Code Creator that is available from Microsoft, which I helped create the consultation to discover the team's services. No more roll

code:

 
Imports System Imports
  System.Management Private Function    isServerInstalled (ByVal    servername As String   )  As Boolean    


   
  Try Dim searcher     As New  ManagementObjectSearcher (_  
                   "root\CIMV2"  , _ 
                   "SELECT * FROM Win32_Service WHERE Name = '"   & servername.ToUpper &   "'"  ) 
               If   searcher.  Get  .Count = 0   Then   
                   Return     False   
               End     If   
   
               For     Each   queryObj   As   ManagementObject   In   searcher.  Get  () 
                   If   queryObj(   "Name"  ).ToString.Equals(servername.ToUpper)   Then   
                       Return     True   
                   Else   
                       Return     False   
                   End     If   
               Next   
           Catch   err   As   ManagementException 
               Return     False   
           End     Try   
       End   Function 

and for use within the page:




   Protected   Sub Page_Load (ByVal    sender As Object   ,  ByVal e    As System.EventArgs) Handles    I . 
  Load If Not    (isServerInstalled ( "MSSQLSERVER" ) OrElse   isServerInstalled ( "MSSQL $ SQLEXPRESS" )) Then   
            Response.Redirect(  "nosqlserver.aspx"  ) 
           End     If   
       End     Sub   

Ready!

0 comments:

Post a Comment