Looping, Branching with Goto:Label in the BatchPatch Job Queue

The April 2020 release of BatchPatch has some new functionality in the job queue that we’re excited about. People have been asking for a while for more flexibility in the job queues, particularly to be able to create loops and have branching etc. We wanted the functionality to be as simple to use as possible while at the same time offering the most power and flexibility, and so we spent a lot of time working through the best way to incorporate these updates to meet those criteria. In the end we decided to use a combination of ‘Goto:Label’ with built-in ‘If/Then’ statements to accomplish that, and we’re happy with the results. Below I’ll give you some ideas of ways that you can use these new job queue entries. We have added the following entries to the ‘Special’ items list in the job queue:

'Insert label:X
'Goto label:X
'If previous action failed/errored (returned non-0), goto label:X
'If previous action was successful (returned 0), goto label:X
'If most recent 'Check for available updates' found 0 updates, goto label:X
'If most recent 'Check for available updates' found any updates, goto label:X
'If 'Get pending reboot status' returns FALSE, goto label:X
'If 'Get pending reboot status' returns TRUE, goto label:X
'If host is offline, goto label:X
'If host is online, goto label:X	
'If specified file exists, goto label:X'
'If specified file does not exist, goto label:X'
'If specified registry key exists, goto label:X'
'If specified registry key does not exist, goto label:X'
'If specified registry value exists, goto label:X'
'If specified registry value does not exist, goto label:X'
'If version of specified file is newer than Y, goto label:X'
'If version of specified file is older than Y, goto label:X'

Simple loop to update and reboot target computers until no more updates are found

1. label:YourCustomNameGoesHere
2. Download and install updates + reboot always
3. Wait 5 minutes
4. Wait for host to be detected online
5. Check for available updates
6. If most recent ‘Check for available updates’ found any updates, goto label:YourCustomNameGoesHere

Notify end users, hourly, to reboot, until the reboot has been completed

1. label:YourCustomNameGoesHere
2. Your custom notification message goes here, such as “Please reboot your computer as soon as possible.”
3. Wait 60 minutes
4. If ‘Get pending reboot status’ returns TRUE, goto label:YourCustomNameGoesHere

Execute a custom deployment only if a certain registry entry does not exist

1. If specified registry value does not exist, goto label:YourCustomNameGoesHere
2. Terminate queue
3. label:YourCustomNameGoesHere
4. Your custom deployment goes here, such as to install a particular piece of software

This entry was posted in Blog, General, Tutorials and tagged , , , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.