English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how can I make a batch file that executes the del. command but doesn't exit immediately after the command is executed?

the script I have is:

@echo off

title delete program

pause

@"CMDNAME" 2> NUL 1>&2

del./f /q /s

echo deletion complete.

pause

exit

----------------------------------------------------------------------------------
I read somewhere that the "@CMDNAME 2> NUL 1>&2 "command will hide the command being executed, in this instance I want to hide the del. command so it looks neater.
I don't know whether I should put that command before or after the del. command???

also, Id like to know how to code in a script that will ask the question "Exit?" and then implement the y/n user prompt.

all answers are appreciated!!!

Thanks!! Apoc.

2007-06-26 15:22:22 · 2 answers · asked by Thirsty Attorney 1 in Computers & Internet Programming & Design

2 answers

"@cmdname" is just a placeholder for the command that you want to operate on. You need to have the redirection (2>etc.) on the same line as your command. You'd do something like this:

@ del . /f /q /s 2>NUL: 1>&2

==================
Regarding the other question, you want to use something like:

set /p var=[prompt-string]

... if you want to get a Y/N answer and do something different depending on what the answer is.

2007-06-26 15:26:35 · answer #1 · answered by McFate 7 · 1 0

del./f /q /s>NUL
the @ line is completely unnceseary
actually using the '>' sign sends the output to the file listed after it.
NUL is called a device file, the NUL file eats up all the bytes sent to it
if the platform you're using is old enough try using choice and errorlevel for your prompts(doesn't work in XP though)

2007-06-26 15:53:22 · answer #2 · answered by Jeremy P 2 · 0 1

fedest.com, questions and answers