First, what version are you using? (9.x.x?)
Then, can you explain this in bit more details, please?
"but when the process is ended the desktop automatically comes back to the prior datasource"
So, before you republish, you have a workbook with both published and local (live) datasource, right? Which of them has the blue chechmark?
Then, do you use "Update workbook to use the published data source"?