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

Posted on 2012-09-13
Last Modified: 2012-09-20

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.
Question by:StewartTechnologies
    LVL 22

    Assisted Solution

    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!


    LVL 82

    Assisted Solution

    Just add "/y" to your command line:n
    et share "SomeShare" /delete /y

    Open in new window

    LVL 37

    Assisted Solution

    by:Gerwin Jansen
    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
    LVL 6

    Accepted Solution


    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
    Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
    Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
    The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now