CA Client Automation

  • 1.  Copy File using VBSCript

    Posted Aug 09, 2011 07:27 AM
    Hello..

    i have a VBScript, which reads the registry values. On Successful comarison of a particular value, i need to replace a File on the Clint machine in particular folder.

    These are the files i created:

    install.cmd: This file has command to execute the vbscript

    Copy.vbs: this VBScript file has the code to read registry values and copy and replace a one XML file-- Test.xml.

    Should I use Asset Job or Software Job..

    Please tell me the procedure.

    Thanks,
    Hari


  • 2.  RE: Copy File using VBSCript

    Posted Aug 15, 2011 01:32 PM
    Do you need the job to run once or periodically?

    I would say, if its a one time thing: run it as a software delivery job (just like - how you deliver any other packages/scripts)
    But if you need to keep running it (say every week), then the asset job would be the way to go.

    Thanks.


  • 3.  RE: Copy File using VBSCript

    Posted Aug 19, 2011 12:39 AM
    Hi,
    for one time, i have successfully executed it as SW delivery job.


    I have some similar packages which i need to run periodically. Could you please povide details how to create it as asset job.

    Package contains:

    1. cmd file- which copies some files in a location and executes the vbscript
    2. vbscript- which reads registry values and updates based on some pre-difined conditions

    Thanks in advance.

    ~Hari


  • 4.  RE: Copy File using VBSCript

    Posted Aug 19, 2011 05:54 AM

    Hari.Saligommula wrote:

    Hi,
    for one time, i have successfully executed it as SW delivery job.


    I have some similar packages which i need to run periodically. Could you please povide details how to create it as asset job.

    Package contains:

    1. cmd file- which copies some files in a location and executes the vbscript
    2. vbscript- which reads registry values and updates based on some pre-difined conditions

    Thanks in advance.

    ~Hari
    Use DMS scripting. If there are VB functions you need which cannot be done with DMS, you can use DMS to create the vbs file when the dms script runs. After the vbs script is created, have the dms script execute it.

    Here is an example:

    '****************************************************************************************************************************
    Dim fIn, fhandle2 as integer

    '*************************************** BUILD .VBS FILE ***********************************************************************

    fIn=OpenFile(ENVGETSTRING("SystemDrive") +"\TEMP\CheckUpdates.vbs",O_WRITE)


    writefile(fIn,"Dim objFSO, objNet, WshShell, TxtobjDefFile")

    writefile(fIn,"Dim strComputerName, strRunDate, strArtFound")

    writefile(fIn,"Dim strTitle, strDesc, strIsInstalled, strBulletin")

    writefile(fIn,"Dim objSearcher, objSearchResult, i, strArticle")


    writefile(fIn,"Const ForReading=1, ForWriting=2, ForAppending=8")


    writefile(fIn,"Set objFSO = CreateObject(""Scripting.FileSystemObject"")")

    writefile(fIn,"Set objNet = WScript.CreateObject(""WScript.Network"")")

    writefile(fIn,"Set WshShell = WScript.CreateObject(""WScript.Shell"")")




    writefile(fIn,"strComputerName = objNet.ComputerName")

    writefile(fIn,"strRunDate = Date")

    writefile(fIn,"strArtFound = ""False"")




    'Check WUA Versions

    Writefile(fIn," Dim oAgentInfo")

    Writefile(fIn," On Error Resume Next")

    Writefile(fIn," Err.Clear")

    Writefile(fIn," Set oAgentInfo = CreateObject(""Microsoft.Update.AgentInfo"")")

    Writefile(fIn," If ErrNum = 0 Then ")


    writefile(fIn," Set TxtWsusVersionFile = objFSO.CreateTextFile("""+ ENVGETSTRING("SystemDrive") +"\TEMP\wuaversions.ini"",True)")



    writefile(fIn," TxtWsusVersionFile.WriteLine(""[WUAVersions]"")")

    writefile(fIn," TxtWsusVersionFile.WriteLine(""ProductVersion="" & oAgentInfo.GetInfo(""ProductVersionString""))")

    writefile(fIn," TxtWsusVersionFile.WriteLine(""MajorVersion="" & oAgentInfo.GetInfo(""ApiMajorVersion""))")

    writefile(fIn," TxtWsusVersionFile.WriteLine(""MinorVersion="" & oAgentInfo.GetInfo(""ApiMinorVersion""))")

    writefile(fIn," TxtWsusVersionFile.Close")


    writefile(fIn," set TxtWsusVersionFile = nothing")

    Writefile(fIn," WuaVersion = oAgentInfo.GetInfo(""ProductVersionString"") ")

    Writefile(fIn," Else ")

    writefile(fIn," Set TxtWsusVersionFile = objFSO.CreateTextFile("""+ ENVGETSTRING("SystemDrive") +"\TEMP\wuaversions.ini"",True)")



    writefile(fIn," TxtWsusVersionFile.WriteLine(""[WUAVersions]"")")

    writefile(fIn," TxtWsusVersionFile.WriteLine(""ProductVersion=0"")")

    writefile(fIn," TxtWsusVersionFile.Close")


    writefile(fIn," set TxtWsusVersionFile = nothing")

    writefile(fIn," Err.Clear")


    Writefile(fIn," End If ")


    writefile(fIn,"Set objSearcher = CreateObject(""Microsoft.Update.Searcher"")")

    writefile(fIn,"objSearcher.Online = True")

    writefile(fIn,"Set objResults = objSearcher.Search(""IsInstalled=0 and Type='Software'"")")

    '
    writefile(fIn," Wscript.echo(""Missing Updates: "" & cStr(objResults.Updates.Count))")


    writefile(fIn,"Set TxtWsusInfoFile = objFSO.OpenTextFile("""+ ENVGETSTRING("SystemDrive") +"\TEMP\wsusinfo.txt"",ForWriting,True)")


    writefile(fIn," TxtWsusInfoFile.WriteLine(""Client application ID: "" & objSearcher.Online & objSearcher.ServerSelection)")



    writefile(fIn," TxtWsusInfoFile.WriteLine(""Can automatically upgrade service: "" & objSearcher.CanAutomaticallyUpgradeService)")

    writefile(fIn," TxtWsusInfoFile.WriteLine(""Client application ID: "" & objSearcher.ClientApplicationID)")

    writefile(fIn," TxtWsusInfoFile.WriteLine(""Online: "" & objSearcher.Online)")

    writefile(fIn," TxtWsusInfoFile.WriteLine(""Server selection: "" & objSearcher.ServerSelection)")

    writefile(fIn," TxtWsusInfoFile.WriteLine(""Service ID: "" & objSearcher.ServiceID)")

    writefile(fIn," TxtWsusInfoFile.WriteLine(""Missing Updates: "" & cStr(objResults.Updates.Count))")





    writefile(fIn," TxtWsusInfoFile.Close")





    writefile(fIn,"If Err.Number = 0 Then")

    writefile(fIn," Set TxtobjDefFile = objFSO.OpenTextFile("""+ ENVGETSTRING("SystemDrive") +"\TEMP\mkbpatches.txt"",ForWriting,True)")


    writefile(fIn," If objResults.Updates.Count > 0 Then")

    writefile(fIn," For i = 0 to objResults.Updates.Count")



    writefile(fIn," For Each strArticle in objResults.Updates.Item(i).KBArticleIDs")



    writefile(fIn,"





    strArtFound = ""True"")





    writefile(fIn,"





    For Each strSBID In objResults.Updates.Item(i).SecurityBulletinIDs")

    writefile(fIn,"






    StrBulletin = strSBID")

    writefile(fIn,"





    Next")


    writefile(fIn,"





    TxtobjDefFile.WriteLine(strComputerName & ""|"" & strRunDate & ""|"" & objResults.Updates.Item(i).Title & ""|"" & strArticle & ""|"" & strBulletin)")

    writefile(fIn,"





    StrBulletin = """" ")



    writefile(fIn," Next")

    writefile(fIn," Next")

    writefile(fIn," End If")


    writefile(fIn,"
    If strArtFound = ""False"" then")


    writefile(fIn," TxtobjDefFile.WriteLine(strComputerName & ""|"" & strRunDate & ""|"" & ""No Missing Updates"" & ""|"" & ""000000"" & ""|"" & ""000000"")")

    writefile(fIn," End If")

    writefile(fIn," TxtObjDefFile.Close")


    writefile(fIn,"Else")




    writefile(fIn," Set TxtobjDefFile = objFSO.OpenTextFile("""+ ENVGETSTRING("SystemDrive") +"\TEMP\mkbpatches.txt"", ForWriting, True)")


    writefile(fIn," TxtobjDefFile.WriteLine(strComputerName & ""|"" & strRunDate & ""|"" & ""MKB ERROR"" & ""|"" & CStr(Err.Number) & ""|"" & Err.Description)")

    writefile(fIn," Err.Clear")


    writefile(fIn,"End If")



    writefile(fIn,"WScript.Quit")

    CloseFile(fIn)







    Dim vbscommand as string

    fhandle2 = OpenFile("C:\TEMP\checkupdates.vbs",0)
    If fhandle2 <> 0 then

    While NOT(EOF(fhandle2))


    ReadFile(fhandle2,vbscommand)

    Wend
    Else

    Print("Cound not find CHECKUPDATES.vbs file.")
    End If
    CloseFile(fhandle2)




    Execute(EnvGetString("COMSPEC") + " /C cscript //nologo " + ENVGETSTRING("SystemDrive") +"\TEMP\CheckUpdates.vbs",TRUE,0)

    '***************************************************************************************************************************