Self Destruct VBS file. How?

Hello Experts,

I fould the following script on the net and it works just fine. What I don't understand is why I can not get to be called as a function from within a Sub. Also I'm curious as to why the word Selfdestruct appears after the End Sub and without it the code does not work. Thanks for any clarification.

Sub SelfDestruct()

Set fs_obj = CreateObject("Scripting.FileSystemObject")
fs_obj.DeleteFile WScript.ScriptFullName
Set fs_obj = Nothing

End Sub

SelfDestruct
LVL 1
donniedarko801Asked:
Who is Participating?
 
hesCommented:
The last SelfDestruct in the script is calling the Sub SelfDestruct()
0
 
leonstrykerCommented:
>What I don't understand is why I can not get to be called as a function from within a Sub.

Because then the function tries to remove the file, it can not since it is locked. The reason it is locked is that the calling procedure is waiting to the result of the Function you are calling.

hes answered your other question.

Leon
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.