mstester Posted September 29, 2006 Share Posted September 29, 2006 Stupid question but if i make a Batch file to delete something and it requires a confirmation i.e. "are u sure y/n?" (for example) is there any way i can put the input into the batch file?Cheers Link to comment Share on other sites More sharing options...
trodas Posted September 29, 2006 Share Posted September 29, 2006 I would bet that if you have enabled the "ask before deletion" then the confirmation pop up. But I assume that you want that even if user have disabled the confirmation when moving files to the trashcan, right? Link to comment Share on other sites More sharing options...
gunsmokingman Posted September 29, 2006 Share Posted September 29, 2006 Try this@Echo OffDel "DeleteTest.txt" /s Link to comment Share on other sites More sharing options...
net_user Posted September 29, 2006 Share Posted September 29, 2006 del file.txt /S Delete specified files from all subdirectoriesdel file.txt /q Quiet mode, do not ask if ok to delete on global wildcardor just do a del /? from the command prompt and it will display the help you need. Link to comment Share on other sites More sharing options...
mstester Posted September 30, 2006 Author Share Posted September 30, 2006 Thanks everyone, it the switch /s worked like a dream!Thanks again guys! Link to comment Share on other sites More sharing options...
Plamdi Posted September 30, 2006 Share Posted September 30, 2006 Thanks everyone, it the switch /s worked like a dream!Thanks again guys!The correct switch is /p. for more information type DEL/? at command prompt. As explained /s will continue deleting the named file from all subdirectories (and will search for it, taking up time and resources!) Link to comment Share on other sites More sharing options...
Yzöwl Posted September 30, 2006 Share Posted September 30, 2006 The correct switch is not /P or /S for that matter!If you use del at the command line or in a cmd file you will not be asked for confirmation on a single file in these scenarios; hidden, system or read-only.If the file is hidden or a system file you will get the following message:Could Not Find X:\SomePath\SomeFile.extIf the file is read only you will get the following message:Access is deniedThe correct switches to use if you want to get rid of a single file without returning either of the two messages is:del/a/f X:\SomePath\SomeFile.ext Link to comment Share on other sites More sharing options...
Plamdi Posted September 30, 2006 Share Posted September 30, 2006 The correct switch is not /P or /S for that matter!If you use del at the command line or in a cmd file you will not be asked for confirmation on a single file in these scenarios; hidden, system or read-only.Well I think we can assume he doesn't want to delete hidden, read only or system files - if he does then that's another matter... there is a reaon for those file attributes, you know! Link to comment Share on other sites More sharing options...
jaclaz Posted September 30, 2006 Share Posted September 30, 2006 (edited) Plamdi,maybe you got it wrong:1) mstester does NOT want a prompt for deleting file(s)2) normally there is NO prompt when deleting a single file UNLESS it is either a Read Only or System file:2a) If it is Read Only, the prompt will be "Access Denied"2b) If it is System, the prompt will be "Cannot find file"3) if you are deleting MORE than one file, using a wild card, like in del *.*, a prompt will come out asking whether you want to proceedSo, the /s will do the same command in each subdirectory, but if you use wildcards, you will be prompted once for each subdirectory.The /q suppresses the prompt generated by MULTIPLE deletes (i.e. using wildcards)the /p will FORCE the (unwanted) prompt for EACH file.the /f forces the deleting of Read Only filesthe /a (optionally followed by the type of attribute) will allow deleting files with particular attributes, /ar is the same as /f, /a means every file but those that are Read OnlySo, if you want to delete files with NO prompt whatsoever, the right syntax isdel /a /fIf, from a batch file or from command line you want to bypass the prompt generated by a wildcard, without pressing S (Y in English) you use:echo S | del \dir\*.*i.e. you pipeline a "S" or a "Y" into the command.If you use the /s parameter, of course only first prompt will be bypassed, this can be useful in some occasion INSTEAD of the /q.jaclaz Edited September 30, 2006 by jaclaz Link to comment Share on other sites More sharing options...
Yzöwl Posted September 30, 2006 Share Posted September 30, 2006 The correct switch is not /P or /S for that matter!If you use del at the command line or in a cmd file you will not be asked for confirmation on a single file in these scenarios; hidden, system or read-only.Well I think we can assume he doesn't want to delete hidden, read only or system files - if he does then that's another matter... there is a reaon for those file attributes, you know!For no reason other than to kick a man when he's down...There is no switch to remove a prompt that you do not get!You can get prompts for wildcard deletions.i.e.del *.txtIn these cases they are not single files, they are 'global wildcards' and will therefore require the /q switch for supression of the resulting prompt(s).i.e.del/q *.txt Link to comment Share on other sites More sharing options...
the_doc735 Posted October 1, 2006 Share Posted October 1, 2006 the /a (optionally followed by the type of attribute) will allow deleting files with particular attributes, /ar is the same as /f, /a means every file but those that are Read Onlyjaclaz/ARhow is this actually written in practice please? i.e. spacing and colon :e.g./A : R/A:R/A: R/A :R ...etc.Cheers! Link to comment Share on other sites More sharing options...
Yzöwl Posted October 1, 2006 Share Posted October 1, 2006 This is not an entire list, but I hope it answers your question!DEL/AR DEL /AR _DEL/ARH DEL /ARH |DEL/ARHS DEL /ARHS |DEL/ARS DEL /ARS |DEL/A:R DEL /A:R All these will delete a single file with a read only attribute, regardless of its system or hidden staus.DEL/A:RH DEL /A:RH |DEL/A:RHS DEL /A:RHS |DEL/A:RS DEL /A:RS |DEL/A/F DEL /A/F ¯ Link to comment Share on other sites More sharing options...
the_doc735 Posted October 2, 2006 Share Posted October 2, 2006 (edited) @ Yzowlthanks for the info!! Also:Windows XP syntaxDeletes one or more files.DEL [/P][/F] [/Q] [/A[[:]attributes]] namesERASE [/P] [/F] [/Q] [/A[[:]attributes]] namesnames Specifies a list of one or more files or directories. Wildcards may be used to delete multiple files. If a directory is specified, all files within the directory will be deleted. /P Prompts for confirmation before deleting each file. /F Force deleting of read-only files. /S Delete specified files from all subdirectories. /Q Quiet mode, do not ask if ok to delete on global wildcard /A Selects files to delete based on attributes attributes R Read-only files S System filesH Hidden files A Files ready for archiving- Prefix meaning notIf Command Extensions are enabled DEL and ERASE change as follows:The display semantics of the /S switch are reversed in that it shows you only the files that are deleted, not the ones it could not find."If Command Extensions are enabled "...could you explain/define what is meant by this statement please? [thanks]. I know what file extensions are, but not command extensions?I've googled "what are command extensions?" and "command extensions explained" and "command extensions" but no immediate answer seems to be available. Microsoft talk about command extensions but without explaining exactly what they are? Edited October 2, 2006 by the_doc735 Link to comment Share on other sites More sharing options...
Ctrl-X Posted October 2, 2006 Share Posted October 2, 2006 "If Command Extensions are enabled "...could you explain/define what is meant by this statement please? [thanks].Command Extensions are enabled by default. You may also disableextensions for a particular invocation by using the /E:OFF switch. Youcan enable or disable extensions for all invocations of CMD.EXE on amachine and/or user logon session by setting either or both of thefollowing REG_DWORD values in the registry using REGEDT32.EXE: HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions and/or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensionsto either 0x1 or 0x0. The user specific setting takes precedence overthe machine setting. The command line switches take precedence over theregistry settings.Type "cmd /?" for details. Link to comment Share on other sites More sharing options...
the_doc735 Posted October 2, 2006 Share Posted October 2, 2006 (edited) Command Extensions are enabled by defaultThey might be enabled by default, BUT WHAT ARE THEY PLEASE?[example answer] Command extensions are......i.e. that's like saying a chef uses a frying pan.A chef may use a frying pan, but what is it?A shallow, long-handled, circular metal container, usually 8, 10 and 12 inches in diameter; used for frying food. Also called skillet; also called regionally fry pan, spider.Hope you understand me better now? many thanks! Edited October 2, 2006 by the_doc735 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now