Del is a command used to delete files from the computer.
|
DEL or ERASE is a command used to delete files from the computer.
|
|
|
names
|
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
|
IMPORTANT WARNING: This command is easy to use, but it is the most dangerous one you will encounter in DOS (apart form FORMAT). If you aren’t careful, you may delete a file which you, the system, or someone else needs. And, unless you have saved a backup of that file, the erased file is gone for good. For this reason it is good practice to use only complete file specifications with the ERASE/DEL command (and to keep backups of your most valuable files). As a safety precaution, never use the wild-card characters '*’ and '?’ in ERASE/DEL commands.
Dim outMsg
If RunDosCommand( "DEL c:\windows\test.doc", outMsg ) Then
Reporter.ReportEvent micPass, "RunDosCommand", "Ended successfully."
Else
Reporter.ReportEvent micFail, "RunDosCommand", outMsg
End If
the example deletes the c:\windows\test.doc in the windows directory if it exists, otherwise an error message will be displayed in the Reporter.
RunDosCommand Function
Public Function RunDosCommand( ByVal cmd, ByRef stdout )
Dim sb, wShell, exec
Dim input
RunDosCommand = False
Set wShell = CreateObject( "WScript.Shell" )
' ** Executing the command
Set exec = wShell.Exec( "%comspec% /C " & cmd )
' ** Checking for errors…
If Not exec.StdErr.AtEndOfStream Then
stdout = "STDERR: " & exec.StdErr.ReadAll
Set exec = Nothing : Set wShell = Nothing
Exit Function
End If
' ** The stringBuilder is faster than concatenation ( & )
Set sb = DotNetFactory.CreateInstance( "System.Text.StringBuilder" )
Do While Not exec.StdOut.AtEndOfStream
input = Trim( exec.StdOut.ReadLine )
' ** Appending only not empty lines
If Len( input ) > 0 Then
sb.AppendLine input
End If
Loop
' ** retieve the output
stdout = sb.ToString
RunDosCommand = True
Set sb = Nothing : Set exec = Nothing : Set wShell = Nothing
End Function
Posted in CommandLine


daniva




Recent Comments