Script for checking IIS - iis-7

Is there a way to check the status of app pools running on IIS using command line?
We have tried to get the status of an app pool by executing a Powershell script but it did not work.
I’m new to IIS. Any inputs would be really helpful.

Related

.NET Core 3.1 Windows Service Fails Immediately with 1053 Timeout Error

I have a .NET Core 3.1 console app I have deployed to server and setup as a windows service. I can open cmd window as admin and navigate to the exe and it runs the exe with no errors or issues.
However when I try to start the Windows Service it immediately fails with an error:
Windows could not start the service on the local computer. Error 1053: The Service did not respond to the start or control request in a timely fashion.
We have ServicesPipeTimeout set to 180000
and rebooted server but it still fails immediately. Shouldn't it take time before the timeout error comes up?
I have also ensured we have the Release version of the code as I found posting saying Debug versions of code will cause this issue.
The folder permissions are as follows:
Since the console app runs fine from the command prompt there should not be an issue with the code/framework on the system?
Is there anything else to check?

Batch File: Wait until multiple dotnet run commands are finished before launching browser shortcut

I have a batch file that executes:
start cmd /k dotnet run -p projectName
For two separate projects and then launches a shortcut link to the angular project in browser. The only (semi) problem is that the shortcut launches before the dotnet run commands have finished and so the browser believes the site cannot be reached until the dotnet run commands are complete.
I'm trying to not launch the shortcut link until both projects have finished executing the dotnet run command so the "This site can't be reached" dialog never shows up. I don't personally mind it, but it's rather confusing to anyone thinking the application should just open without the need for a reload.
EDIT:
The projects I'm running are a .NET Core Web API & .NET Core (Angular) Web App. The angular app get's compiled and served via dotnet run, but both projects need to remain running in order to listen to their specific ports. And the shortcut link executed at the end of the batch file is just to open the browser at localhost:AngularPort#. I understand a desktop app would have probably been the way to go from the start but for v2, the plan is to host in azure and allow customers to access the site as well instead of just being an internal app.
I found a solution on npm with a package called 'wait-on' which in my case will wait until an http(s) request on that url returns a response with a status code in the 200 range before completing. There's a whole other assortment of use-cases with this package but I only needed it for that.
Here's a link to the package if anyone else runs into this problem:
https://www.npmjs.com/package/wait-on
Edit:
Honestly this was only a problem because the laptop I needed to put the application on didn't have the best CPU stats, so it got hung up trying to serve a local api and angular application simultaneously.

How to make process start when running in IIS

When I add the site to run in IIS, my process.start() does not work to open the process. It only runs locally. Is there a way to make that method also work in IIS?

Shell.Invoke doesn't launch the powershell script in deployed asp.net web application

I wrote an asp.net web application, which launches a powershell script. The program ran without any issue when I debugged it in my development environment. After publishing and deploying the asp.net web application (by the way the target server is the same machine localhost), by clicking the button for launching the powershell script, nothing happened. It means the powershell script was not launched. I attached the debugger to the deployed asp.net and saw that the Shell.Invoke() was hit as before and the command was also correct. However Shell.Invoke() returned immediately and the powershell script was not launched. In my environment the powershell execution policy is RemoteSigned.
Since the program in the development environment works perfectly and in the deployed case also hits the same code, I don't think it has to do with the code but more with security, certification,...???
Has anyone experienced the same? If yes, please advise me what I should do.
I appreciate your help in advance.
Thx
Might have something to do with the application pool identity not having the right permissions:
You might want to run your PowerShell invocation from a system service with explicit permissions though. That will take a steeper curve though.

Invoke an application using webservice

I'm trying to write a web service on my server windows server2008 to invoke some applications on my server. I user system.diagnostics.process class to invoke exe files. It works fine on server itself, but when i use the webservice over a different pc, I got error message which is specified file not found. But when I just launch cmd.exe it works fine too. As far as i understand I have access to server which i can run at least cmd.exe on. But when it comes to invoke different exe's it just doesn't work. I have another clue too, when I run the cmd.exe remotely it runs, and I try to kill it remotely then it gives me the error "Access denied".
I'm not familiar with this kind of server access,permission jobs. Hence I need some help.
Any help would be appreciated :)
You need to make sure that the Application Pool in IIS in running as a user that has permission to execute the executables on that server.
Just a word of warning (as you may know): this is a huge security risk if you expose these services out to anywhere. Opening up a service to run an application can be risky so I would make sure that there's no other way to do what you're trying to accomplish.

Resources