开发者

How can i restart MSDTC service on remote server from client machine

I have requirement to restart MSDTC service on a remote开发者_开发问答 server throw code of my application . Could you please help me through a code example.

Thanks and Regards ShaBeg


This should do the trick

System.ServiceProcess.ServiceController sc = 
    new System.ServiceProcess.ServiceController("Distributed Transaction Coordinator", "MachineName");
sc.Stop();
sc.Start();

The account under which the code is running will need to have admin rights on the remote box though. If not, you can do impersonation before running the code to impersonate a user with admin rights on the remote box.

MSDN info on the ServiceController class:
http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx


You can use the SC or Netsvc tools as described in this technet article.

sc \\machine stop "Distributed Transaction Coordinator"
sc \\machine start "Distributed Transaction Coordinator"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜