Friday, August 6, 2010

Visual basic script to check the status of a MOSS 2007 solution

A simple VB script that I wrote about 2 years back to automate solution deployment.

dim strSolutions , intReturnValue
strSolutions = "There are no items matching the criteria specified."
intReturnValue = 2 'solution not installed

Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\stsadm -o enumsolutions")

strSolutions = objScriptExec.StdOut.ReadAll
strSolutions = Trim(strSolutions)

pos=InStr(1,strSolutions,"There are no items",1)
if pos = 0 then

Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.loadXML(strSolutions)

Dim objCurrNode, strDeployStatus
Set objCurrNode = objxmlDoc.selectSingleNode("/Solutions")

for each xmlTmpNode in objCurrNode.ChildNodes
strAttValue = xmlTmpNode.getAttribute("Name")
if lcase(strAttValue) = "" then
set ElementsList= xmlTmpNode.getElementsByTagName("Deployed")
for each Elem In ElementsList
strDeployStatus = Elem.firstChild.nodeValue
if LCase(Trim(strDeployStatus)) = "true" then
intReturnValue = 4 'solution installed & deployed
else
intReturnValue = 3 'solution installed BUT NOT deployed
end if
next
exit for
end if
next
end if

Wscript.Quit(intReturnValue)

No comments:

Post a Comment