Knowing the real path
If you do not know the specific path, you can use the following code:
Wscript.ScriptFullName Returns the actual path of the script.
Delete self: vbs
Save the following script as selfkill.vbs or selfkill.vbe :
f = fso.DeleteFile(WScript.ScriptName)
And then run it, isn’t it discovery selfkill.vbs Has the magic disappeared? And the dialog box behind is displayed normally^*^
The above script calls the FSO control, uses the scriptname attribute of the WSH wsscript object to get the script’s own file name,
And call FSO’s deletefile method to delete itself!
Rewrite it a little bit:
Set fso = CreateObject(“Scripting.FileSystemObject”)
WScript.Sleep 1000 ‘suspend script execution for 1 second
fso.DeleteFile ( WScript.ScriptName ）’delete script itself
If fso.FileExists (“c:\ selfkill.exe “) Then fso.DeleteFile (“c:\ selfkill.exe “) ‘delete program
The program can dynamically generate VBS self delete script and call it to delete itself. The method is similar to batch file self delete!
It should be noted that due to the abuse of viruses and worms to scripts, scripts may be mistaken for malicious code when deleting files!