June 18, 200521 yr 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, 200521 yr by Fascix
June 18, 200521 yr 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
June 19, 200521 yr It should work, but in general you should use the del /F /Q command to make sure that writeprotected also are deleted without request.
June 20, 200521 yr Author Delprat: Yes ofcourse, thats right. ThanxDoc Symbiosis: Good point ill make sure ill apply that to the cleanupt that needs it. Thanx
June 21, 200521 yr 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\*.*"
June 21, 200521 yr 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, 200521 yr by gunsmokingman
Create an account or sign in to comment