Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement vbs background running bat to delete its own code

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to achieve vbs background running bat to delete their own code", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve vbs background running bat to delete their own code" this article.

If you know the real path,

Set fso=wscript.createobject ("scripting.filesystemobject") fso.deletefile "c:\ windows\ system32\ run.cmd" fso.deletefile "c:\ windows\ system32\ run.vbs"

If you don't know the specific path, you can use the following code:

Set fso = CreateObject ("Scripting.Filesystemobject") fso.DeleteFile (WScript.ScriptFullName)

Wscript.ScriptFullName returns the actual path to the script.

Delete your own: VBS

Save the following script as selfkill.vbs or selfkill.vbe:

Set fso = CreateObject ("Scripting.FileSystemObject") f = fso.DeleteFile (WScript.ScriptName) WScript.Echo (WScript.ScriptName)

And then run it, did you find that selfkill.vbs magically disappeared? However, the later dialog box is displayed normally.

The above script calls the FSO control, uses the ScriptName property of the Wscript object in WSH, and gets the file name of the script itself.

And call the DeleteFile method of FSO to delete itself!

Rewrite it a little bit:

On Error Resume Next 'prevent errors 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 a VBS self-deletion script and call it to delete itself, the method is also similar to the self-deletion of batch files!

It should be noted that due to the misuse of scripts by viruses and worms, scripts may be mistaken for malicious code when deleting files!

The above is all the contents of this article "how to implement vbs background running bat to delete its own code". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report