简体   繁体   中英

Powershell script to execute .exe file in sequential manner

There is a web site called "lt" running on port 8700 on apache. When the web site is down I need to show a "Service Maintenance Message" in the web page. For that I have hosted a site (Web Page) hosted on IIS on port 80. When "lt" is down (ie once ltshutdown.exe is run)I want to route it to IIS web page. And then after proper maintenance of "lt", I want to put it back online (ie stop IIS and ltstartup.exe is run ). I think power shell script can do it. But I have less knowledge on that. Can you guys help me out to write a script to this? Or else any easy sugesstions?

Thanks!

RM

Uncommon scenario as a there are better ways to have a maintenance page (Check these links: link1 link2 ).

Assuming you have valid reasons to do it this way and also assuming that both IIS and Apache are in same box.

I would change IIS site to be also in port 8700. That means that you would not be able to have both running at the same time, something pretty positive in this scenario.

You should have two scripts:

  1. StopIT
  2. StartIT

StopIT Script

Import-Module WebAdministration
# Stop IT
& C:\scripts\itshutdown.exe
# Start IIS site
Start-WebSite 'ITMaintenanceSite'

StartIT Script

Import-Module WebAdministration
# Stop IT
& C:\scripts\itstart.exe
# Start IIS site
Stop-WebSite 'ITMaintenanceSite'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM