none
Split the value in Vbscript RRS feed

  • Question

  • Hi Can anyone tell me how to split the below value in Vbscript.

    I have wrote a script to check McAfee LastUpdateCheck of remote server and the problem I am facing is when I get the ouputreport, the value come like this "20160210050318".I just want only the date to come in the output file in the format (Eg:20160210)

    Please reffer the part of the script below and please let me know how I need to use split command to split the value, so that the correct date will come the output as well.

    Wscript.Echo strComputer

    hDefKey = HKEY_LOCAL_MACHINE

    strComputer = line
    Set StdOut = WScript.StdOut
    Set oReg=GetObject( _
        "winmgmts:{impersonationLevel=impersonate}!\\" &_ 
        strComputer & "\root\default:StdRegProv")

    strKeyPath = "SOFTWARE\Wow6432Node\Network Associates\TVD\Shared Components\Framework"
    strValueName = "LastUpdateCheck"
    oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
    WScript.Echo "SOFTWARE\Wow6432Node\Network Associates\TVD\Shared Components\Framework" _
        & "CrashControl\LastUpdateCheck" _
        & " = " & StringValue

    LastUpdateCheck = strValue
    wscript.echo  LastUpdateCheck
    'LastUpdateCheck = Split(LastUpdateCheck)

    Wednesday, February 10, 2016 12:33 PM

Answers

All replies

  • Hi,

    As long as the number of digits is fixed you can use Left:

    http://ss64.com/vb/left.html


    • Marked as answer by Mcteer Thursday, February 11, 2016 1:31 PM
    Wednesday, February 10, 2016 2:25 PM
  • Hi Mike,

    Thanks for the reply.

    I have gone through the link,But I haven't got correct idea about that.

    Can you please help me with an example ?

    Wednesday, February 10, 2016 4:05 PM
  • Hi Mike,

    Thanks for the reply.

    I have gone through the link,But I haven't got correct idea about that.

    Can you please help me with an example ?


    What is wrong with the examples in the link?  We cannot do better than that.

    \_(ツ)_/

    Wednesday, February 10, 2016 4:23 PM
  • I gave like this and it was not working for me.

    LastUpdateCheck = Split("LastUpdateCheck", 9) 

    Wednesday, February 10, 2016 4:25 PM
  • So you didn't even read the link.  Go back and read Mike's link.

    \_(ツ)_/

    Wednesday, February 10, 2016 4:28 PM
  • Thanks Mike.

    I am not good in Vbscript, so it took time for me to understand.But finally it works for me.

    I have one more doubt to be clarified. I need to query two registry keys to get McAfee lastheckupdate (i.e one is in older windows version and one is in new windows version). The problem now is when I do a query like below it query only the last registry value and I am getting output for only new windows OS.

    Can you please let me know what correction need to be done on this ?

    hDefKey = HKEY_LOCAL_MACHINE
    strComputer = line
    Set StdOut = WScript.StdOut
    Set oReg=GetObject( _
        "winmgmts:{impersonationLevel=impersonate}!\\" &_ 
        strComputer & "\root\default:StdRegProv")

     
    If strKeyPath = "SOFTWARE\Wow6432Node\Network Associates\TVD\Shared Components\Framework" 

    Then
    strValueName = "LastUpdateCheck"
    oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
    WScript.Echo "SOFTWARE\Wow6432Node\Network Associates\TVD\Shared Components\Framework" _
        & "CrashControl\LastUpdateCheck" _
        & " = " & StringValue

    LastUpdateCheck = strValue
    strValue = left (strValue, 8 )
    'wscript.echo strValue

    Else 

    strKeyPath = "SOFTWARE\Network Associates\TVD\Shared Components\Framework"
    strValueName = "LastUpdateCheck"
    oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
    WScript.Echo "SOFTWARE\Network Associates\TVD\Shared Components\Framework" _
        & "CrashControl\LastUpdateCheck" _
        & " = " & StringValue

    LastUpdateCheck = strValue
    strValue = left (strValue, 8 )
    'wscript.echo strValue

    End If

    output.WriteLine Hostname & "," & strValue

    • Edited by Mcteer Thursday, February 11, 2016 3:19 PM
    Thursday, February 11, 2016 1:43 PM
  • New question needs a new topic.  Topic title needs to be the basic question like "Why does my WMI registry query not work".

    \_(ツ)_/

    Thursday, February 11, 2016 5:22 PM