Apronk - I did try your code all that happens is a number 2 comes up in the cmd window, SMS does not run.

Mart & Benny - have done as you suggested and currently my code is looking like below, but it still has issues -
when running all I get come up is

 Quote:
winmgmts:\\.\root\cimv2t Host' t\cimv2SELECT * FROM Win32_OperatingSystem\\.\roo

then script ends...sms does not install.
 Code:
Dim $strServerLocatorPoint
Dim $strSiteCode
Dim $strSMSInstall
Dim $strSMSLogText
Dim $strComputer
Dim $strSMSClient
Dim $errReturnCode

$strServerLocatorpoint = "$servername"
$strSiteCode = "33e"
$strSMSInstall = "NO"
$strSMSLogText = ""
$strComputer =  "."
$strSMSClient = ""
$errReturnCode = ""

;Read WMI to get state of SMS client
;------------------------------------
;

$objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\cimv2")
$SMSService = $objWMIService.ExecQuery("SELECT * FROM Win32_Service WHERE DisplayName = 'SMS Agent Host' ")

SMSServiceCheck()

If errReturnCode <> "0"
    SMSInstallCheck()
    If strSMSInstall = "YES"
	SMSInstall()
    endif
Else
    $SMSService = objWMIService.ExecQuery("SELECT * FROM Win32_Service WHERE DisplayName = 'SMS Remote Control Agent' ")
    SMSServiceCheck()
EndIf


;'*********************************
;'*Subroutines & Functions follow *
;'*********************************

function SMSServiceCheck()
;------------------

$errReturnCode = "99"

For Each $objService in $SMSService

    If $objService.State <> "Running"
	$errReturnCode = $objService.Change( , , , , "Automatic")
	$errReturnCode = $objService.StartService()
        $strSMSLogText = $objService.Displayname + " restarted from Login Script"
	SMSLogEvent()
    else
    $errReturnCode = $objService.Change( , , , , "Automatic")

    endif

Next

Endfunction


function SMSInstall()
;-------------

$strSMSClient = "\\" + $strServerLocatorPoint + "\SMSClient\i386\CAPINST.EXE /SLP=" +
$strServerLocatorPoint + " /ADVCLI /ADVCLICMD SMSSITECODE=" + strSiteCode

$objShell = $CreateObject("WScript.Shell")
	$objShell.Run ("$strSMSClient")

$strSMSLogText = "SMS Client installed from Login Script"
SMSLogEvent()

Endfunction


function SMSLogEvent()
;--------------

Global $EVENT_SUCCESS = 4
$objShell = $CreateObject("wscript.Shell")
$objShell.LogEvent EVENT_SUCCESS, $strSMSLogText

$strSMSLogText = ""

Endfunction


Function SMSInstallCheck()
;-----------------------

$HKEY_LOCAL_MACHINE = "&H80000002"

$strSMSInstall = "NO"
$strSMSServer = "0"
$strSMSProductSuite = ""
$strSMSType = ""
$strSMSVersion = ""
$strMIPSvalue = ""
$strComputer = "."

;Lets make sure we only install on WS with no MIPS exceptions

$objWMIService = $GetObject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2")
$colOperatingSystems = $objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")

For Each $objOperatingSystem in $colOperatingSystems
    $strSMSServer = $InStr(objOperatingSystem.Caption, "Server")
    $strSMSProductSuite = $objOperatingSystem.OSProductSuite
    $strSMSType = $objOperatingSystem.OSType
    $strSMSVersion = $Left(objOperatingSystem.Version, 1)
Next



;Check for MIPS Exclusion

$objReg = $GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\default:StdRegProv")

$strKeyPath = "SOFTWARE\CSC\EDM\SMS\ClientConfig\Exclusions\MIPS"
$strEntryName = "ExclusionID"
$objReg.GetStringValue = "$HKEY_LOCAL_MACHINE,$strKeyPath,$strEntryName,$strMIPSValue"



;Lets work out if we should install a new client

If $strSMSServer <> "0" or $strSMSProductSuite <> "" or $strSMSType <> "18" or $strSMSVersion = "4" or $strMIPSValue <> ""
 $strSMSInstall = "NO"
else
 $strSMSInstall = "YES"
EndIf

EndFunction





Edited by jules666 (2007-02-13 04:27 PM)