How to disable replication when Distribution db is lost?
Finally, I have found a solution. Problem was that I was calling the stored procedures from query windows of Management Studio (some stored procedures must be called from sqlcmd).

Then, it is enough to follow instructions for TSQL (with @no_checks and @ignore_distributor).