Video Screencast Help
Search Video Help Close Back
to help
Not able to make it to Vision this year? Get a sampling in the Best of Vision on Demand group.

Task Server: Using Conditions in Jobs/Tasks

Updated: 05 May 2011 | 8 comments
LTDSecurity's picture
0 0 Votes
Login to vote
This issue has been solved. See solution.

Hello All,

   I have a simple issue that for some reason I can not seem to resolve (it's been one of those weeks already!).

   I have create a schedules task/job (Symantec Management Platform, Task Server) that I would like to look at the return results of a few vbscripts. Below is one of the vbscripts that will either return True (if the registry key exists) or False (the registry key does not exist) .

WScript.Echo checkForKey

Function checkForKey
On Error Resume Next
Dim oReg,strKeyPath,subkey
Dim strComputer,strKeyValue
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
strKeyValue = "Install"

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
    If InStr(subkey,strKeyValue) <> 0 then
     checkForKey = "False"
    Else
     checkForKey = "True"
    End If
Next
End Function

  I have the condition set on the task/job as follow "If (Job Name) - Return Value Equals True Then", run Job1, Else run Job2,Job3 Stop

 

  The issue is that no matter what the (Job Name) - Return Value actually equals, it runs Job1. I have tried where (Job Name) - Return Value Equals "True" and "If (Job Name) - Return Value Does Not Equals -1 and still it continues to run Job1 then just stops.

 I have manually ran the vbscripts against the test machines and they do return the correct values.

  What I am missing here?

TIA,

Larry 

Comments

TGiles's picture
04
May
2011
0 Votes 0
Login to vote

Try modifying your script to

Try modifying your script to return 0 or 1. I believe 1 should be considered True, but its been a while since I've played with Task Server jobs.

LTDSecurity's picture
04
May
2011
0 Votes 0
Login to vote

Ok.....

OK will give that a shot.

LTDSecurity's picture
04
May
2011
0 Votes 0
Login to vote

Ok lets try again

After re-re-reading my post I meant to that "If (Job Name) - Return Value Does Not Equals True Then", run Job1, Else run Job2,Job3 Stop. And I tried where (Job Name) - Return Value Does Not Equals "True". The image in the previous post was after I added the correct job to run and I did not change the Equal to Does Not Equal.

Like I said it has been one of those weeks for me!

I am trying what @TGiles posted.

Larry

LTDSecurity's picture
04
May
2011
0 Votes 0
Login to vote

Ok that didnt work

@TGiles solution didnt work, thanks anyways.

When I run the vbscript manually, if the key does not exists it returns 0 or False and 1 for True. I added the qoutes before and after True/False so the function would return the text value of True or False as well.

Edited for type for True/False values

LTDSecurity's picture
04
May
2011
0 Votes 0
Login to vote

Reworked Code...

Ok looked @ code again and found an issue, re-worked it...trying again

LTDSecurity's picture
04
May
2011
0 Votes 0
Login to vote

Update....

According to the image below, the 1st If statement was Evaluated as True (meaning the registry key exists), yet, the Job1 was ran instead of going to the Else statement and running Job2 and Job3.

LTDSecurity's picture
04
May
2011
0 Votes 0
Login to vote
LTDSecurity's picture
04
May
2011
0 Votes 0
Login to vote

Ok problem solved

Ok I changed the condition to "If (Job Name) - Return Value Equals False" and ofcourse it works now. Nothing to see now, please move along!