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)
'***************************************************************************************************************************