Restarting the web server from your program
来源:互联网 发布:smali to java 编辑:程序博客网 时间:2024/05/19 09:16
IntroductionHave you ever been asked to deploy a new version of a web application to production? Typically, you will have to do the following:
In this article, I will introduce a small utility program that can be used to install, uninstall, start, and stop all windows services. In particular, you can use it to start/stop the IIS web server. I am aware of other good articles about windows services on this site. My intention is provide a tool that busy (and lazy) developers can use without bothering with all the details, please study the source code or other related articles if you really want to learn more about windows services. The name of the utility program is ServiceInstaller.exe. For your convenience, I have included the executable with the source code. To install a Windows service, you need to run the following at the command prompt: ServiceInstaller -i NameOfService FullPathOfExecutable AccountToUse PasswordOfAccount For example, ServiceInstaller -i myService c:/myService/myService.exe myDomain/myID myPassword If you omit the last two arguments, the service will be using the local system account. By the way, the account you use should be granted the privilege to run services. The command to uninstall the service is much simpler: ServiceInstaller -u NameOfService After installing the service, you can start (run) the service with the following command: ServiceInstaller -r NameOfService [other arguments for the service] And here is the command to stop (kill) the service: ServiceInstaller -k NameOfService Now I will show you how to use this tool to shutdown and restart the IIS Web Server. The situation is actually a little more complicated because there may be other services depending on the IISADMIN service. If you simply try to shutdown IISADMIN, it will probably fail. The list of services depending on IISADMIN may be different on each machine. On my workstation, for example, there are three other services depend on IISADMIN. They are: World Wide Web Publishing Service (W3SVC), FTP Publishing Service (MSFTPSVC), and Network News Transport Protocol (NNTPSVC). What we need to do is shutdown all services depending on IISADMIN first and then shutdown IISADMIN itself: ServiceInstaller -k W3SVCServiceInstaller -k MSFTPSVCServiceInstaller -k NNTPSVCServiceInstaller -k IISADMIN The following commands will restart the four services we have shutdown: ServiceInstaller -r IISADMINServiceInstaller -r NNTPSVCServiceInstaller -r MSFTPSVCServiceInstaller -r W3SVC Actually, starting any service depending on IISADMIN will also start IISADMIN itself (so the first command in the above is unnecessary). Writing a Windows service is a little trickier, but you don't have to do it (fortunately). My article Start Your Windows Program From An NT Service introduces a special Windows service that can make other programs behave like a service. Please visit my home page for my other tools and articles. Thanks. Xiangyang Liu
|
- Restarting the web server from your program
- the program can't start because cygwin1.dll is missing from your computer
- The program can’t start because MSVCR100.dll is missing from your computer.
- I get the prompt window "Restarting your computer is required"
- Server & Client some code from the web
- 安装wampserver出现“The Program can't start because MSVCR110.dll is missing from your computer. Try reinstalling the program to f
- The program can't start because Qt5Cored.dll is missing from your computer最简单的解决方法
- Fix "the ECDSA host key for 'your server' differs from the key for the IP address 'the ip'"
- get the password from ipclient program
- DCMTK-Configure the logger from a program
- keystone -- An unexpected error prevented the server from fulfilling your request. 错误
- github安装问题解决"Unable to retrieve your user info from the server"
- github问题之Unable to retrieve your user info from the server
- An unexpected error prevented the server from fulfilling your request. (HTTP 500)
- 161.In your database instance, the user sessions are connected to the database server from the remot
- Protecting your Web Apps from the Tyranny of Evil with OWASP
- SharePoint debug - Unable to render the data. If the problem persists, contact your web server admin
- Don't Nail Your Program into the Upright Position
- API hooking revealed
- HookAPI source code
- Driver Development Part 1: Introduction to Drivers
- Using MC.exe, message resources and the NT event log in your own projects
- Start Your Windows Programs From An NT Service
- Restarting the web server from your program
- Creating a website from the command line
- 7.ASP内建对象Request
- 1.Are you ready?
- 2.ASP简介
- 3.ASP基础
- 4.ASP脚本基础
- 6.ASP脚本循环语句
- 8.ASP内建对象Response