Last active
July 14, 2020 18:44
-
-
Save sdesalas/6533286 to your computer and use it in GitHub Desktop.
This script restarts IIS and configures it on a remote server. Needs Sysinternals PsExec (http://technet.microsoft.com/en-au/sysinternals/bb897553.aspx)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Stop IIS | |
PsExec.exe \\LDNSERV01 -s -i C:\windows\system32\inetsrv\appcmd.exe stop site OnlineXCart | |
:: Recycle App Pool (removes lock on file system) | |
PsExec.exe \\LDNSERV01 -s -i C:\windows\system32\inetsrv\appcmd.exe recycle apppool OnlineXCart | |
:: Wait 4 Seconds | |
:: This is useful if you have a command straight after that executes file operations on IIS App Directory | |
ping -n 5 127.0.0.1 > nul | |
:: Modify IIS Physical Path Remotely | |
PsExec.exe \\LDNSERV01 -s -i C:\Windows\system32\inetsrv\appcmd.exe set config -section:system.applicationHost/sites /[name='OnlineXCart'].[path='/'].[path='/'].physicalPath:"D:\websites\OnlineXCart\${WEBAPP_VERSION}\Main" /commit:apphost | |
:: Start IIS | |
PsExec.exe \\LDNSERV01 -s -i C:\windows\system32\inetsrv\appcmd.exe start site OnlineXCart |
It works fine, thank you!
Hi @sdesalas @agray,
Do you encounter any 404 problem while your ci server is deploying?
I used this code to close site and app pool. Then i copied files and started site and app pool
Our load balancer sends request to closed site and it gives 404 error.
How can i handle this? Do you have any suggestion? Do i need to change steps(site closing-app pool closing)?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that the user executing this command should have (admin?) access on \LDNSERV01