Conditional server stop/start

I have a .Net application that can be run as an application and sometimes also as a service. If I add "stop service" and "start service" as update actions and run it with an installation that does not have the service installed it will fail.Can the update action for restarting the service be conditional or if the service does not exist it will not fail but continue with the update?