开发者

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

开发者 https://www.devze.com 2022-12-26 00:57 出处:网络
I have requirement to restart MSDTC service on a remote开发者_开发问答 server throw codeof my application .

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

精彩评论

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