locked
Vb Script not working when running as advertisement from SCCM RRS feed

  • Question

  • Hi,

    This is Phani, am trying to push an advertisement from SCCM server to individual systems where I can get "Oracle Edition" and "Version" from REGISTRY to a shared location.

    When the code is ran from a single individual system, the report has been generating and "Ora.csv" file has been creating in the shared location(\\hs-sccmpri\OracleEdition\Orc.csv), but it's not working when it's running from SCCM for all the systems, but we got script is running successfully.

    Following is the VB Script code:

      

    Const ForAppending = 8
    Set wshShell = CreateObject("WScript.Shell") 
    Set wshNetwork = WScript.CreateObject( "WScript.Network" )
    strTempDir = wshShell.ExpandEnvironmentStrings("%temp%")
    Set fso = CreateObject("Scripting.FileSystemObject") 
    strComputerName = wshNetwork.ComputerName

    On Error Resume Next

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Ora = WshShell.RegRead("HKLM\SOFTWARE\ORACLE\inst_loc")

    If (IsNull(Ora)) Then

    wshShell.Run "REGEDIT /E %temp%\registry.txt HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Oracle", 0, True
    wshShell.Run "cmd /c type %temp%\registry.txt | find /i ""ORACLE_BUNDLE_NAME"" > %temp%\OracleEdition.txt", 0, True
    wshShell.Run "cmd /c type %temp%\registry.txt | find /i ""ORACLE_HOME_NAME"" > %temp%\OracleHome.txt", 0, True

    else

    wshShell.Run "REGEDIT /E %temp%\registry.txt HKEY_LOCAL_MACHINE\SOFTWARE\Oracle", 0, True
    wshShell.Run "cmd /c type %temp%\registry.txt | find /i ""ORACLE_BUNDLE_NAME"" > %temp%\OracleEdition.txt", 0, True
    wshShell.Run "cmd /c type %temp%\registry.txt | find /i ""ORACLE_HOME_NAME"" > %temp%\OracleHome.txt", 0, True

    End If

    set objFSO = createobject("Scripting.FileSystemObject")
    set LogFile = objFSO.OpenTextFile("\\hs-sccmpri\OracleEdition\Orc.csv",ForAppending, True)
    LogFile.writeline Date & "," & Time

    If fso.FileExists(strTempDir & "\registry.txt") Then
    Set tsIn = fso.OpenTextFile(strTempDir & "\OracleEdition.txt", 1)
    StringFromFile = tsIn.ReadAll  
    OracleEdit = Mid(StringFromFile, 23, 10)
    wshShell.Run "cmd /c tnsping > %temp%\OracleVersion.txt", 0, True

    Set objFile = FSO.OpenTextFile(strTempDir & "\OracleVersion.txt", 1)
    StringFromFile2 = ObjFile.ReadAll
    OracleVer = Mid(StringFromFile2, 48, 10)

    Set tsIn = fso.OpenTextFile(strTempDir & "\OracleHome.txt", 1)
    StringFromFile = tsIn.ReadAll  
    OracleHome = Mid(StringFromFile, 24, 10)

    'Write here your own file share (e.g \\testserver\Oracle\OracleVersion.txt)
    set objFSO = createobject("Scripting.FileSystemObject")
    set LogFile = objFSO.OpenTextFile("\\hs-sccmpri\OracleEdition\Orc.csv",ForAppending, True)
    LogFile.writeline strComputerName & "," & OracleEdit & "," & OracleVer & "," & OracleHome


    Else
      Set LogFile = FSO.OpenTextFile("C:\Temp\OracleInfo.txt", 8, 1)
      LogFile.Write(strComputerName)
      LogFile.WriteLine(" ")
      LogFile.WriteLine("No Oracle Installed")
      LogFile.WriteLine(" ")
    End If

    Please suggest me a solution.

    Thanks in advance.

    Regards,

    Phani T


    Tuesday, April 23, 2013 6:54 AM

Answers

All replies