Uninstall, Reboot, Install - Within a Single Action

I understand that a Baseline can be used to perform this sequence, but I wanted to know if it could all be done in a single action. The uninstall and install are under a minute each, but the best success is to have a reboot after the uninstall. Then when the system comes back up, it picks up where it left off.

Is that even possible?

1 Like

I recommend creating a small baseline to do that. We do it for things like BIOS/firmware updates.

Here is an example of how we would do a BIOS update baseline:
Task 1: Do pre-req steps such as disable security software and suspend BitLocker.
Actionscript 1 (end):

action requires restart
restart 60

Task 2: Do BIOS/firmware/application install/upgrade/etc
Actionscript 2 (end):

action requires restart
restart 60

Task 3: Do post-install validation check

Task 4: Re-enable security software and resume BitLocker
Actionscript 4 (end):

action requires restart
restart 60

It is important in such a baseline that the restarts are called by Bigfix actionscript commands, not native OS commands (shutdown.exe, etc). If native commands are used, the agent will interprete the reboot as a failure and not continue. If it is actionscript command, then it will proceed with the baseline as planned.

In some situations, where your upgrade/script is trying to run immediately after boot that it may fail as perhaps not all services are fully up and the OS service registry is locked. In that case, insert a short ‘pause’ at the start of the task.

Example of a ‘pause’:

wait PowerShell.exe -NonInteractive -NoLogo -Command Start-Sleep -Seconds 60

I have another situation where being able to run something, reboot, and run something else would be helpful (all within a single action).

In this case, running a PS Remove-WindowsPackage -Online -PackageName P1 reboot, then run the Cleanup-Image.

Sounds like this is not do-able though in a single action, huh?

If you need a reboot in between, then I would recommend multiple actions that have relevance to cause them to run in a sequence, or a baseline.

An action can never span a reboot unless the action runs twice and does one thing before the reboot and a different thing after the reboot, which is technically possible. ( If installed uninstall and reboot, if not installed, then install ) This would be the only way to do this with a single task/fixlet.

Technically a baseline is a single parent action with sub actions.

  • Why does this need to be done as a single task/fixlet and not a baseline?
  • Is there a reason why a baseline is not a good option?
  • Is it because you can’t put a baseline inside a baseline?
  • Can you provide a bigger picture of what the use case is?

In my opinion it is best to have every task/fixlet be as simple as possible and use multiple in a baseline when required.

The second task is so simple it hardly warrants its own fixlet, but I agree, best to keep things simple. I’ll probably just have two fixlets in a phase 1/2 approach. Thanks for the response.

I think this has come up before, but I do have another thought on it. If you are really concerned about using a baseline rather than a single fixlet, then you could have one Fixlet to uninstall the application, and schedule a Scheduled Task to run at next bootup to do the Cleanup-Image statement.

You won’t have great status about whether the Scheduled Task is successful though.

I have done this before with relevance. I setup the first fixlet to do the uninstall and added a action requires restart at the end so that it gets flagged for reboot. The second action would have relevance that indicates the original software is not installed AND that a reboot is not required. Also if you really want to be sure that the install only happens on computers that you uninstalled from you could add a custom registry flag to the uninstall fixlet and then remove it after the upgrade is successful.

Uninstall Fixlet:
Remove Old Software
Flag Registry with HKLM\Software<custom key><title>UpgradeCantidate=true
Flag with Reboot Required

Install Fixlet:
Add relevance to look for Reboot NOT required AND has custom registry key indicating that it needs an upgrade.
Remove custom registry key once complete.

Still 2 different fixlets but no baseline required.

That’s pretty much what I did. I did a Part 1, Part 2 task. Part 1 does its thing and set a reg key, Part 2 then is relevant to that key, does its thing, then deletes the key. It’s been working great.

Thanks for your suggestion!