Fascix Posted June 18, 2005 Share Posted June 18, 2005 (edited) HiSorry for this but i was just woundering how a command line in a batch file would look like if i want it to automaticly answer Yes or No.I have a batch file i made (cleanup.cmd)but some of the commands prompt me like this: (är du säker J/N?)whitch is Swedish for (Are you sure Y/N?)so a line like this prompt me to answer Yes or No:DEL "%systemroot%\Web\Wallpaper\*.*" How would the line look if i want it to automaticly say Yes?Ill try to search in cmd help some more in the meenwhileEDIT:is this right?DEL "%systemroot%\Web\Wallpaper\*.* /Q" Thanx Edited June 18, 2005 by Fascix Link to comment Share on other sites More sharing options...
Delprat Posted June 18, 2005 Share Posted June 18, 2005 This is right :DEL /Q %systemroot%\Web\Wallpaper\*.*-> the "/Q" switch must be right after the "DEL" command (as you can see with DEL /?)-> The quotes are needed ONLY when using file names/pathes with spaces (1st line below), and you can use them only on the "path part with spaces" (2nd line below) :DEL /Q "%systemdrive%\Program Files\blablabla\*.*"DEL /Q %systemdrive%\"Program Files"\blablabla\*.*bye Link to comment Share on other sites More sharing options...
Doc Symbiosis Posted June 19, 2005 Share Posted June 19, 2005 It should work, but in general you should use the del /F /Q command to make sure that writeprotected also are deleted without request. Link to comment Share on other sites More sharing options...
Fascix Posted June 20, 2005 Author Share Posted June 20, 2005 Delprat: Yes ofcourse, thats right. ThanxDoc Symbiosis: Good point ill make sure ill apply that to the cleanupt that needs it. Thanx Link to comment Share on other sites More sharing options...
matthewk Posted June 21, 2005 Share Posted June 21, 2005 If you come into a case where you do not have a handy switch, this method will work for you:echo y | DEL "%systemroot%\Web\Wallpaper\*.*" Link to comment Share on other sites More sharing options...
gunsmokingman Posted June 21, 2005 Share Posted June 21, 2005 (edited) You could also use a vbs file to delete the stuff.Things In Green Are The Part Of The Script That Perform The ActionThings In Orange Are Safe To Remove From ExamplesThings In Blue Are The Objects Needed For Various Task, These Are LikeCmd Promt Ping Dir Tree, But Are More Powerful Than Cmd Promts.Example One This Runs A Check Then Will Delete Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject") Dim Act :Set Act = CreateObject("Wscript.shell") Dim Sd : Sd = Act.ExpandEnvironmentStrings("%systemdrive%") Dim Wd : Wd = Act.ExpandEnvironmentStrings("%Windir%") Dim RmWd RmWD = (Wd & "\Web\Wallpaper") If Fso.FolderExists(RmWD) Then Fso.DeleteFile(Wd & "\Web\Wallpaper\*.*") MsgBox RmWD Else End IfExample 2 On Error Resume Next = If This Is Not There Then You Will NotGet A Error Message Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject") Dim Act : Set Act = CreateObject("Wscript.shell") Dim Wd : Wd = Act.ExpandEnvironmentStrings("%Windir%") On Error Resume Next Fso.deleteFile(WD & "\Web\Wallpaper\*.*)Example 3 This Will Work Only From The Drive That The Script Start From EG If This Script Was Started From E and Windows Is On C Then It Would Produce A Error. If The Script Is Ran From The Same Drive That Windows Is Installed On Then It Will Work. Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject") Fso.DeleteFile( "\Windows\Web\Wallpaper\*.*")Example 4 Same As Example 3 But Has A Error ControlOn Error Resume NextCreateObject("Scripting.FileSystemObject") .DeleteFile( "\Windows\Web\Wallpaper\*.*") Edited June 21, 2005 by gunsmokingman 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