How to code in auto "yes" response in .bat script.

Hello-

I am writing a basic windows .bat file to stop a network share. It is asking for a y/n and enter input before it can stop the share.

e.g net share folder \\server /delete

How do i code in the "yes" to automatically complete my program without manual input.

Note: The script will be a scheduled task, so it needs to auto run without manual input.
StewartTechnologiesIT ConsultantAsked:
Who is Participating?
 
Manuel Marienne-DuchêneConnect With a Mentor ITMCommented:
0
 
Christopher McKayConnect With a Mentor Microsoft Network AdministratorCommented:
You could try using an echo command to pipe to the net share command. Have you tried this:

echo y | net share folder \\server /delete


Hope this helps!

:o)

Bartender_1
0
 
oBdAConnect With a Mentor Commented:
Just add "/y" to your command line:n
et share "SomeShare" /delete /y

Open in new window

0
 
Gerwin Jansen, EE MVEConnect With a Mentor Topic Advisor Commented:
Hi, I don't get the y/n question, but you can try adding /yes like this:

net share folder \\server /delete /yes

Or try this:

echo y | net share folder \\server /delete
0
 
StewartTechnologiesIT ConsultantAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.