I will be show the problem first and the real question is in last paragraph.

Now I make the replication between 2 servers. The agent the be choosed in this case is merge agent. Most time that it work fine but it alway got the error in many time. This is my problem...

I want to replicate from Server1 to Server2. The problem I found is the process on Server2 still running after some error occur and the process on Server1 is stopped by itself. And the process on Server1 cannot be connect to Server2 in next time because the old one still running.

My way to correct this error is delete old PUSH for down the old process that still running on Server2. And re-create new PUSH with restart the snapshot too. If I'm not restart the snapshot the replicate will be failed and I don't know WHY.

I want to add 2 step of action before replication step is start.
1. Try to stop the old process that still running on Server2.
2. Resart the snapshot.
How can I add it? and What code to do something like this?