Navigation:  Scripting > System Scripts >

System Script Obsolete Functions

Previous pageReturn to chapter overviewNext page

The following system script functions are no longer included with Visual Build Pro v6.  Either convert your projects to use the replacement actions documented below, or copy the script code below into your global script code.

 

Note: the Service action can be used in place of these scripts and provides a simpler method for stopping and starting services.

 

vbld_ConnectServer(strServer, strUserName, strPassword): Connect to a remote server using WMI and return the server object.

 

vbld_GetService(strServer, strServiceName, strUserName, strPassword): Retrieve a WMI object reference to a remote service.

 

vbld_RemoteStartService(strServer, strServiceName, strUserName, strPassword): Start a remote service, returning True if started or False if already running.

 

vbld_RemoteStopService(strServer, strServiceName, strUserName, strPassword): Stop a remote service, returning True if stopped or False if already stopped.

 

 

Note: the COM+ Application and COM+ Component actions provide more functionality and should be used instead of the following scripts.

 

vbld_CreateApplication(strName, blnServer): Create/update a COM+ application, returning True if it did not exist or False if it already existed.

 

vbld_DeleteApplication(strName): Delete a COM+ application, returning True if it existed or False if it did not exist.

 

vbld_AddComponent(strApp, strDll): Install a component into a COM+ application, returning True if added or False if the application was not found.

 

 

Note: the IIS Virtual Dir action provides more functionality and should be used instead of the following scripts.

 

vbld_CreateVirtualDir(strPath, strName): Create/update an IIS virtual directory on the default web site to the specified path.

 

vbld_DeleteVirtualDir(strName): Delete an IIS virtual directory on the default web site.

 

 

Obsolete Script Code

 

' Connect to a remote server using WMI and return the server object

Function vbld_ConnectServer(strServer, strUserName, strPassword)

 

   Dim objLocator

 

   'Create Locator object to connect to remote CIM object manager

   Set objLocator = CreateObject("WbemScripting.SWbemLocator")

 

   'Connect to the namespace which is either local or remote

   Set vbld_ConnectServer = objLocator.ConnectServer(strServer, "root\cimv2", strUserName, strPassword)

   vbld_ConnectServer.Security_.impersonationlevel = 3

 

End Function

 

' Retrieve a WMI object reference to a remote service

Function vbld_GetService(strServer, strServiceName, strUserName, strPassword)

 

   Dim objServer

 

       Set objServer = vbld_ConnectServer(strServer, strUserName, strPassword)

   Set vbld_GetService = objServer.Get("Win32_Service='" &  strServiceName & "'")

       

End Function

 

' start a remote service, returning True if started

' use "", "" for username and password if the current user has remote execute rights,

' otherwise specify a valid username/password for the remote server

Function vbld_RemoteStartService(strServer, strServiceName, strUserName, strPassword)

 

   Dim objService

 

       Set objService = vbld_GetService(strServer, strServiceName, strUserName, strPassword)

       vbld_RemoteStartService = (objService.StartService() = 0)

       

End Function

 

' stop a remote service, returning True if stopped

' use "", "" for username and password if the current user has remote execute rights,

' otherwise specify a valid username/password for the remote server

Function vbld_RemoteStopService(strServer, strServiceName, strUserName, strPassword)

 

   Dim objService

 

       Set objService = vbld_GetService(strServer, strServiceName, strUserName, strPassword)

       vbld_RemoteStopService = (objService.StopService() = 0)

       

End Function

 

' create/update a COM+ application, returning True

' if it did not exist

Function vbld_CreateApplication(strName, blnServer)

 

       Const COMAdminActivationInproc = 0

       Const COMAdminActivationLocal = 1

 

       Dim cllApps, objApp, i

       

       vbld_CreateApplication = False

       Set cllApps = vbld_ApplicationCollection

       i = vbld_FindCollectionIndex(cllApps, strName)

       If i >= 0 Then        ' update existing item if found

               Set objApp = cllApps.Item(i)

       Else                        ' add new app if not found

               Set objApp = cllApps.Add

               objApp.Value("Name") = strName

               vbld_CreateApplication = True

       End If

       

       If blnServer Then

               objApp.Value("Activation") = COMAdminActivationLocal

       Else

               objApp.Value("Activation") = COMAdminActivationInproc

       End If

       cllApps.SaveChanges

               

End Function

 

' delete a COM+ application, returning True

' if it existed

Function vbld_DeleteApplication(strName)

 

       Dim objCat, cllApps, objApp, i

       

       vbld_DeleteApplication = False

       

       Set objCat = CreateObject("COMAdmin.COMAdminCatalog")

       Set cllApps = objCat.GetCollection("Applications")

       

       i = vbld_FindCollectionIndex(cllApps, strName)

 

       If i >= 0 Then

               objCat.ShutDownApplication(strName)

               cllApps.Remove i

               cllApps.SaveChanges

               vbld_DeleteApplication = True

       End If

               

End Function

 

' add a component to a COM+ application, returning True

' if added or False if the application was not found

Function vbld_AddComponent(strApp, strDll)

 

       Dim objCat, cllApps, objApp, i

       

       vbld_AddComponent = False

       Set objCat = CreateObject("COMAdmin.COMAdminCatalog")

       Set cllApps = objCat.GetCollection("Applications")

       

       i = vbld_FindCollectionIndex(cllApps, strApp)

       

       If i >= 0 Then

               objCat.InstallComponent cllApps.Item(i).Key, strDll, "", ""

               vbld_AddComponent = True

       End If

       

End Function

 

' locate the given COM+ admin collection object by name and return

' its 0-based index or -1 if not found

Function vbld_FindCollectionIndex(cll, strName)

 

       Dim i, obj

       

       cll.Populate

       

       vbld_FindCollectionIndex = -1

       i = 0

       For Each obj In cll

               If LCase(obj.Name) = LCase(strName) Then

                       vbld_FindCollectionIndex = i

                       Exit For

               End If

               i = i + 1

       Next

       

End Function

 

' create an return the COM+ Applications collection

Function vbld_ApplicationCollection()

 

       Dim objCat, cllApps

       

       Set objCat = CreateObject("COMAdmin.COMAdminCatalog")

       Set cllApps = objCat.GetCollection("Applications")

       cllApps.Populate

       Set vbld_ApplicationCollection = cllApps

       

End Function