Start/Stop Window Service from ASP.NET page

爷,独闯天下 提交于 2019-12-10 21:09:19

问题


Is there a way to start / stop a windows service of a server in a different network

(not \\<server name>) from an asp.net page?

I tried using ServiceController but it's only work if it's in the same network.


回答1:


RE: ServiceController How to Start/Stop a Windows Service from an ASP.NET app - Security issues

Anything you can do from command line or powershell can be ran from a page (assuming the app pool user has correct permissions etc)

  • https://serverfault.com/questions/429426/how-can-i-connect-to-a-windows-server-using-a-command-line-interface-cli
  • Run Command Prompt Commands
  • How To: Execute command line in C#, get STD OUT results

Powershell is probably your best bet for managing services on a remote server though this will require the server to allow remote powershell.

  • Calling Powershell from C# (ASP.NET) - pass custom object?
  • http://www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C

and of course for the topic of powershell resetting/stopping remote services.

  • http://www.powershellmagazine.com/2012/08/28/pstip-starting-and-stopping-services-on-remote-computers/
  • How to start/stop a service on a remote server using PowerShell - Windows 2008 & prompt for credentials?

Google is definitely your friend on this one :)



来源:https://stackoverflow.com/questions/17097292/start-stop-window-service-from-asp-net-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!