Alright, I think you’re getting confused about the approach here.
We have to do a couple things:
- Get a list of our Scheduled Tasks
- Wrap each scheduled task in our schtasks.exe command line
- Put carriage returns between each schtasks.exe line so they run as separate commands.
- Make it into a fixlet
We can never proceed to the next step until the previous step is working. If our original relevance for getting the scheduled tasks doesn’t work then our fixlet is doomed to fail.
I have a scheduled task called AT4 that should match yours.
Get a list of Scheduled Tasks
This relevance (using the scheduled task inspectors) should appropriately pull each of your scheduled tasks:
Q: names of scheduled tasks whose ((path of it = "%22C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\BES Support\changeservicestartmode.exe%22" and argument string of it = "BESClient auto") of (action of definition of it as exec task action))
A: AT4
A: AT5
Wrap each scheduled task with schtasks.exe (from Jason)
To do this we will add ("schtasks.exe /delete /TN " & it & " /F") of ...
to our relevance. The important part here is the & it &
. For each of our scheduled tasks, it will put the name of the task where that is is and generate our command line.
Q: ("schtasks.exe /delete /TN " & it & " /F") of names of scheduled tasks whose ((path of it = "%22C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\BES Support\changeservicestartmode.exe%22" and argument string of it = "BESClient auto") of (action of definition of it as exec task action))
A: schtasks.exe /delete /TN AT4 /F
A: schtasks.exe /delete /TN AT5 /F
Now, if we take this relevance and put it into an appendfile in actionscript what happens?
ActionScript:
appendfile {("schtasks.exe /delete /TN " & it & " /F") of names of scheduled tasks whose ((path of it = "%22C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\BES Support\changeservicestartmode.exe%22" and argument string of it = "BESClient auto") of (action of definition of it as exec task action))}
We get this:
Contents of __appendfile
schtasks.exe /delete /TN AT4 /Fschtasks.exe /delete /TN AT5 /F
Put carriage returns between each schtasks.exe line
Next we need to put some new lines between our schtasks.exe so they run as separate commands. To do this we use the concatenation "%0d%0a" of ...
relevance that Jason provided:
Q: concatenation "%0d%0a" of ("schtasks.exe /delete /TN " & it & " /F") of names of scheduled tasks whose ((path of it = "%22C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\BES Support\changeservicestartmode.exe%22" and argument string of it = "BESClient auto") of (action of definition of it as exec task action))
A: schtasks.exe /delete /TN AT4 /F%0d%0aschtasks.exe /delete /TN AT5 /F
Now this might not look right yet but if we make it into actionscript:
Actionscript:
appendfile {concatenation "%0d%0a" of ("schtasks.exe /delete /TN " & it & " /F") of names of scheduled tasks whose ((path of it = "%22C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\BES Support\changeservicestartmode.exe%22" and argument string of it = "BESClient auto") of (action of definition of it as exec task action))}
Contents of __appendfile:
schtasks.exe /delete /TN AT4 /F
schtasks.exe /delete /TN AT5 /F
Make it into a fixlet
Actionscript:
delete __appendfile
appendfile {concatenation "%0d%0a" of ("schtasks.exe /delete /TN " & it & " /F") of names of scheduled tasks whose ((path of it = "%22C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\BES Support\changeservicestartmode.exe%22" and argument string of it = "BESClient auto") of (action of definition of it as exec task action))}
delete run.bat
move __appendfile run.bat
wait run.bat
I would make the removal of the other scheduled tasks, the cmd.exe /c net start besclient into another fixlet and develop/test them separately.