Monday, December 3, 2018

Run WebServices and Windows services on IIS Express using command prompt or batch file

To run web and windows services in IIS Express through command prompt or batch file, we can create a batch file with the following changes:

cd "C:\Program Files (x86)\IIS Express"
start iisexpress /config:"path to your project source code repository\.vs\config\applicationhost.config" /site:WebSiteName
In applicationhost.config make changes as below:

  • Look for something like below for the WebSiteName above

  <sites>
            <site name="WebSite1" id="1" serverAutoStart="true">

  • Update physicalPath to correct path:

physicalPath="VirtualDirectory of WebSite" /> 

  • or copy all the bin(assembly) files as seen below:
    bin=> has all dll's of the web service
    Web.config should detail the hosting details of all services.




Other Windows services can be started as below:

  1. Create a shortcut to the windows service with command line arguments if any.
  2. In batch file add this line:
  3. start "Service title" /b "Path of shortcut to windowsservice.exe shortcut"