• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 646
  • Last Modified:

Provide a "Y" answer to a batch file

Hi,

I have the following batch script called dropShares.bat:

net share sharename1 /delete
net share sharename2 /delete
net share sharename3 /delete
net share sharename4 /delete

The "net share" command will sometimes prompt me for a response, thus stopping the batch script.  How can I suppress this behavior, or provide several "Y" values?

0
a222493
Asked:
a222493
  • 3
  • 2
  • 2
1 Solution
 
softplusCommented:
echo y | net share sharename1 /delete
:)
0
 
a222493Author Commented:
I type:

echo y | net share applications /delete

and I receive the error:
No valid response was provided.


Am I missing something???

0
 
sirbountyCommented:
try net share applications /delete /y
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
a222493Author Commented:
Wow,  You've gotta be kidding me.  I never even tried it because I thought it would be documented....

Thanks
0
 
softplusCommented:
can you try it without the spaces around the pipe-symbol (|):
   echo y|net share applications /delete

I tried it with something else (echo y | del \temp\*.*) and it worked.. What question is it asking?
0
 
softplusCommented:
good one sirbounty :)
0
 
sirbountyCommented:
It's the little things, eh?
Happy to have helped. 8-)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now