VBScript - Self Deleting Script
9
This script demonstrates the use of a function that allows a script to delete itself from disk. The function can be called from anywhere within the script and the script will continue to function normally (assuming the script does not further attempt to access itself on disk). Handy for homebrew uninstallation programs that require the removal of all installation files, including the setup file.
Option Explicit
MsgBox "Before the self delete", vbInformation, "Self Deleting Script"
'Delete the script
DeleteSelf
MsgBox "After the self delete", vbInformation, "Self Deleting Script"
Sub DeleteSelf()
Dim objFSO
'Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Delete the currently executing script
objFSO.DeleteFile WScript.ScriptFullName
Set objFSO = Nothing
End Sub
Comments
Thu. Feb. 22nd, 2007 4:11 PM
sv
sv
Voting
Votes Up
BrandonReese
ColdKeyboard
ctiggerf
dannyboy
i_kenneth
Pio
Sonsam
sundaramkumar
TimboTheGreat





