Pipe "y" into net stop on windows

I want to stop a service without being prompted. This is what I tried:

C:\>echo y|net stop WAS
The following services are dependent on the Windows Process Activation Service service.
Stopping the Windows Process Activation Service service will also stop these services.

   World Wide Web Publishing Service

Do you want to continue this operation? (Y/N) [N]:
No valid response was provided.

I want to do this within batch job.


Solution 1:

There is a undocumented parameter that works with net commands, /y or /yes which bypasses the prompt. So in your case it would be:

net stop WAS /y