I don't know of any way, as we don't run program 2 until program 1 has run successfully.
What you'd need to do is either have your own wrapper program that would look to see if program 1 is installed, and if so, then kick off the uninstall. That way it would successfully run in either case.
Or, you'd have to configure collections to do proper app detection, and only target those that do have program 1 installed.