This is the error msg that you get when trying to to a rerun on a chained advertisement.
By a chained advertisement i mean that the advertisement will run several programs in a chain. Example:
I though this was very strange since i know ive used rerun on chained programs in SMS so I started digging and here is what i found out:
SCCM rightclick tools use the ReRunAdv.wsf script for rerunning programs.
This script is located on the following path: "C:\WINDOWS\SCCMTools\ReRunAdv.wsf"
In the function called "SetRerunBehavior" beginning on row 143 we can see the root of the why the script is not working.
We will get errors if the following query get more then 1 result.
Set objScheds = objNMS.ExecQuery("select * from CCM_SoftwareDistribution where ADV_AdvertisementID = '" & strAdvID & "'" )
Because of the following row (161):
if (objScheds.Count <> 1) then
This basiclly means that if we get more or less then 1 row when running the query we will get an error code of "-3" when running this function.
So why do we get more then one result?
Well this is because we have a chained advertisement which means we will get one row for each program in the chain. This is how it look in wbemtest (namespace: "\\<COMPUTERNAME>\root\ccm\policy\machine\actualconfig" ) when running this query:
So what we can do to make the advertiemsent rerun is either to alter the WQL query or we could simply change row 163
FROM
SetRerunBehavior = -3
TO
SetRerunBehavior = 0
This will make the script able to process this function with exit code 0, which in turn will make the script complete without error.
Since it will be able to get past this step now:
' Then make sure the program can be rerun
ret = SetRerunBehavior(strMachine, strAdvID, strOldRerunBehavior, "RerunAlways")
If ret < 0 then
MsgBox "Unable to set RerunBehaviour. Program will not rerun.", vbCritical OR vbOKOnly, "Rerun Advertisement Error"
Wscript.Quit(ret)
Else
' wscript.echo "Successfully set RerunBehaviour from " & strOldRerunBehavior & " to RerunAlways."
End If
I have tested this in two enviroments now and it´s working great in booth. I will tell you if i find any buggs with this solution.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Hi guys
A coupple of days ago a colleuge told me that he was having problems rerunning chained advertisements with the rightclick tools in SCCM.
SCCM Right click tolls can be downloaded from here: http://myitforum.com/cs2/blogs/rhouchins/0424ConfigMgrTools.zip
This is the error msg that you get when trying to to a rerun on a chained advertisement.
By a chained advertisement i mean that the advertisement will run several programs in a chain. Example:
I though this was very strange since i know ive used rerun on chained programs in SMS so I started digging and here is what i found out:
SCCM rightclick tools use the ReRunAdv.wsf script for rerunning programs.
This script is located on the following path: "C:\WINDOWS\SCCMTools\ReRunAdv.wsf"
In the function called "SetRerunBehavior" beginning on row 143 we can see the root of the why the script is not working.
We will get errors if the following query get more then 1 result.
Because of the following row (161):
This basiclly means that if we get more or less then 1 row when running the query we will get an error code of "-3" when running this function.
So why do we get more then one result?
Well this is because we have a chained advertisement which means we will get one row for each program in the chain. This is how it look in wbemtest (namespace: "\\<COMPUTERNAME>\root\ccm\policy\machine\actualconfig" ) when running this query:
So what we can do to make the advertiemsent rerun is either to alter the WQL query or we could simply change row 163
FROM
TO
This will make the script able to process this function with exit code 0, which in turn will make the script complete without error.
Since it will be able to get past this step now:
' Then make sure the program can be rerun
ret = SetRerunBehavior(strMachine, strAdvID, strOldRerunBehavior, "RerunAlways")
If ret < 0 then
MsgBox "Unable to set RerunBehaviour. Program will not rerun.", vbCritical OR vbOKOnly, "Rerun Advertisement Error"
Wscript.Quit(ret)
Else
' wscript.echo "Successfully set RerunBehaviour from " & strOldRerunBehavior & " to RerunAlways."
End If
I have tested this in two enviroments now and it´s working great in booth. I will tell you if i find any buggs with this solution.
Share this post
Link to post
Share on other sites