How to pass Yes automatically in a batch script?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
lalat06bag
Posts: 51
Joined: 10 Jan 2018 15:21

How to pass Yes automatically in a batch script?

#1 Post by lalat06bag » 10 Dec 2018 11:19

Hi,

I have this piece of code.

SET "NASS=\\abc"
SET "TEMPDIR=%NASS%\CU\OR"
PUSHD "%TEMPDIR%"
forfiles /s /m *.* /c "cmd /c Del @path" /d -90
POPD

While executing, it asks \\abc\CU\OR\*, Are you sure (Y/N) ? and the job stops there till the input is provided.

Now how to pass Y in the above code?

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How to pass Yes automatically in a batch script?

#2 Post by aGerman » 10 Dec 2018 11:34

That's a typical XY question. You don't need to pass Yes but you have to pass /Q as the help for DEL states.

Steffen

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: How to pass Yes automatically in a batch script?

#3 Post by Squashman » 10 Dec 2018 11:41

The FORFILES command is grabbing files and folders. When the script tries to delete a folder it will prompt you with that. It will not prompt to delete files.

lalat06bag
Posts: 51
Joined: 10 Jan 2018 15:21

Re: How to pass Yes automatically in a batch script?

#4 Post by lalat06bag » 10 Dec 2018 13:55

correct. Thank you. now i made that silent by passing /Q.

Post Reply