Tip:

4 delete commands available - when to use which

 

There are 4 different script commands available in Visual Installer's scripting language that can be used to delete files (DELETE, MDELETE, RDELETE, XDELETE) and in this tip we will explain what the differences are and when to use which.
 
 
DELETE
 
The DELETE command is the standard delete command in Visual Installer's scripting language and this is the one that is normally used. It just deletes a file at a specified path (if it is possible). The syntax for the command is:
 
DELETE  %Filename
  
%Filename Full path to file to delete. The path can contain variables (for example %DESTDIR).
 
Below is an example of how to use the command:
 
DELETE %DESTDIR\Temp\TempFile.dta
 
In the example above a file named TempFile.dta is deleted at the specified path.
 
 
MDELETE
 
If you need to delete many files at the same time, the MDELETE command can be used for this purpose. The MDELETE command support wildcards (for example *.txt or *.*). The syntax for the command is:
 
MDELETE  %Filename
  
%Filename Files to delete. Wildcards can be used, ex: "C:\Data\*.*" or "%DESTDIR\Data\*.txt".
 
Below is an example of how to use the command:
 
MDELETE %DESTDIR\DataFiles\*.dta
 
In the example above all files with the filename extension .dta are deleted in the specified folder. All other files in the same folder are unaffected.
 
 
RDELETE
 
Sometimes a file that need to be deleted during an installation is in use and therefore locked by the system. It can not be deleted at that time. To handle this situation in a proper way, the RDELETE command in Visual Installer's scripting language can be used.

When you use the RDELETE command, no attemts to delete the file is made during the installation. Instead the file is flagged for deletion, and during the next computer reboot (computer restart) the file is deleted by the system.
 
The syntax for the command is:
 
RDELETE  %Filename
  
%Filename Full path to file to delete. The path can contain variables (for example %DESTDIR).
 
Below is an example of how to use the command:
 
RDELETE %DESTDIR\CleanUp\CleanUp.exe
 
In the example above a file named CleanUp.exe in the specified path is flagged for deletion during the next computer restart.
 
 
XDELETE
 
Sometimes a file can be write protected. A write protected file can not be deleted using the script commands described above (for security reasons). But if you really need to delete a write protected file, the XDELETE command can be used. The syntax for the command is:
 
XDELETE  %Filename
  
%Filename Full path to file to delete. The path can contain variables (for example %DESTDIR).
 
Below is an example of how to use the command:
 
XDELETE %DESTDIR\MyData\MyData.dta
 
In the example above a file named MyData.dta at the specified path is deleted also if it is write protected (has the write protection attribute turned on).

You should use this command with care. If a file is write protected, there may be a good reason for that, and you should only delete the file when you are absolutely sure.
 
 
Summary
 
Below is a short summary of the 4 script commands described above:
 
DELETE Deletes a file.
MDELETE Deletes many file at the same time (wildcards are supported).
RDELETE Flags a file for deletion at the next system reboot.
XDELETE Deletes a file, also if it's write protected.
 
 
   
  
See also
Visual Installer's Scripting Language
 
   

< Tips Index Page
   

Go to Visual Installer product page Visual Installer Tip
 
Only Professional Version
SamLogic