[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Self Destruct VBS file. How?

Posted on 2006-03-28
Medium Priority
Last Modified: 2013-12-25
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

Question by:donniedarko801
LVL 20

Accepted Solution

hes earned 2000 total points
ID: 16312913
The last SelfDestruct in the script is calling the Sub SelfDestruct()
LVL 29

Expert Comment

ID: 16373281
>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.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question