Jump to content

Short batch file question!


Recommended Posts

Hi

Sorry 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 meenwhile

EDIT:

is this right?

DEL "%systemroot%\Web\Wallpaper\*.* /Q"

Thanx

Edited by Fascix
Link to comment
Share on other sites


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

You could also use a vbs file to delete the stuff.

Things In Green Are The Part Of The Script That Perform The Action

Things In Orange Are Safe To Remove From Examples

Things In Blue Are The Objects Needed For Various Task, These Are Like

Cmd 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 If

Example 2

On Error Resume Next = If This Is Not There Then You Will Not

Get 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 Control

On Error Resume Next

CreateObject("Scripting.FileSystemObject") .DeleteFile( "\Windows\Web\Wallpaper\*.*")

Edited by gunsmokingman
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...