Client Management Suite

 View Only
Expand all | Collapse all

Using vbscript return values with conditions in jobs/tasks

  • 1.  Using vbscript return values with conditions in jobs/tasks

    Posted Feb 29, 2012 09:29 PM

    Hi all,

     I have searced the forums for an answer but not found one that will work with what I want to do. I need to get the Return Value of the "Get Operating System Version" job and based on the value I have conditions set in the "Latest Adobe Flash Player for Internet Explorer" job. Basically if the OS Version is 32 then run the 32bit job and if the OS Version is 64 then run the 64bit job. The issue for me seems to be able to get the return value from the "Get Operating System Version" I have tried a few different ways to do this, but do not seem successful. I am assuming that as long as I do a wscript.echo that is the "return value" from the script. When I look at the "Get Operating System Version" task results it shows the correct OS Version, but the conditions always bomb out and if the return value equals 64 it always fails.
     
     I do not want to use the MSD policies for this, I want a service desk tech just to be able to run the job and not have to figure out what version the OS is. Any help would be greatfull!

    TIA, Larry

     
    Job/Task: Get Operating System Version
    wscript.echo getOSVersion

    Function getOSVersion()
    ' script will return either 32 or 64
    Dim ObjProc
    strComputer = "."
    For each ObjProc in GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
     strComputer & "").ExecQuery ("Select AddressWidth from Win32_Processor")
     getOSVersion = CInt(ObjProc.AddressWidth)
    Next
    ObjProc = ""
    End Function 

    Job/Task: Latest Adobe Flash Player for Internet Explorer

       



  • 2.  RE: Using vbscript return values with conditions in jobs/tasks



  • 3.  RE: Using vbscript return values with conditions in jobs/tasks
    Best Answer

    Posted Mar 01, 2012 03:02 AM

    Check if you have "Save script output with task status" set in your script.

    If this is checked, your script will always return "0" (success) ... uncheck it and retry.

    Should be a bug.

    @Edit:

    oh ... and you have to use wcript.quit() instead of wscript.echo() to return the code.



  • 4.  RE: Using vbscript return values with conditions in jobs/tasks

    Posted Mar 01, 2012 10:32 AM

    Thanks Minstral, I will try to uncheck the Save script option. I saw the wscript.quit(valuesgoeshere) in another forum post, but that failled the job in the first step (Get OS Version), and didnt out put anything.



  • 5.  RE: Using vbscript return values with conditions in jobs/tasks

    Posted Mar 01, 2012 10:33 AM

    Thanks R.Dupriest I will check those links out when I start back on this later today!



  • 6.  RE: Using vbscript return values with conditions in jobs/tasks

    Posted Mar 01, 2012 11:14 AM

    Hi Minstral,

     I have unchecked the "Save script output with task status" option and changed the wscript.echo(getOSVersion) to wscript.quit(getOSVersion) and below is error message I received from the client job that is using this task.

    Error Image:


     
    Task: Get Operating System Version
    wscript.quit(getOSVersion)

    Function getOSVersion()
    ' script will return either 32 or 64
    Dim ObjProc
    strComputer = "."
    For each ObjProc in GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
     strComputer & "").ExecQuery ("Select AddressWidth from Win32_Processor")
     getOSVersion = CInt(ObjProc.AddressWidth)
    Next
    ObjProc = ""
    End Function



  • 7.  RE: Using vbscript return values with conditions in jobs/tasks

    Posted Mar 01, 2012 11:16 AM

    R,Dupriest, thanks for the links, I took a look at them and I dont want to have to create custom tokens for this. This should be simple enough to do out of the box.



  • 8.  RE: Using vbscript return values with conditions in jobs/tasks

    Posted Mar 01, 2012 12:00 PM

    Thats fine ... Return Code: 64 ... its a 64BitOS ...

    You just have to uncheck the "Fail Job if any Task fails" checkbox, because it will always "fail" (being not 0 ... so either 32 or 64).



  • 9.  RE: Using vbscript return values with conditions in jobs/tasks

    Posted Mar 01, 2012 12:41 PM

    OMG I didnt even see the return code! Thanks!



  • 10.  RE: Using vbscript return values with conditions in jobs/tasks

    Posted Mar 01, 2012 02:03 PM

    Mistral,

       That fixed the issue, I am now good to go. Just need to educate the SD Techs to look at the failure code to make sure it is either a 32 or 64 so they dont automatically assume the job failed, thanks!



  • 11.  RE: Using vbscript return values with conditions in jobs/tasks

    Posted Mar 01, 2012 02:24 PM

    You can add a second 32Bit condition and add an else "error branch", so techs see at first sight which way the job went without checking the error code.

     

    Would be nice if you mark this thread as solved if you are good to go.