VBS runs bat in the background to delete its own code


Knowing the real path

Copy codeThe code is as follows:
set fso=wscript.createobject(“scripting.filesystemobject”)
fso.deletefile “c:\windows\system32\run.cmd”
fso.deletefile “c:\windows\system32\run.vbs

If you do not know the specific path, you can use the following code:

Copy codeThe code is as follows:
Set fso =CreateObject(“Scripting.Filesystemobject”)

Wscript.ScriptFullName Returns the actual path of the script.

Delete self: vbs

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

Copy codeThe code is as follows:
Set fso = CreateObject(“Scripting.FileSystemObject”)
f = fso.DeleteFile(WScript.ScriptName)
WScript.Echo( 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:

Copy codeThe code is as follows:
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 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!

Recommended Today

PHP 12th week function learning record

sha1() effect sha1()Function to evaluate the value of a stringSHA-1Hash. usage sha1(string,raw) case <?php $str = “Hello”; echo sha1($str); ?> result f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 sha1_file() effect sha1_file()Function calculation fileSHA-1Hash. usage sha1_file(file,raw) case <?php $filename = “test.txt”; $sha1file = sha1_file($filename); echo $sha1file; ?> result aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d similar_text() effect similar_text()Function to calculate the similarity between two strings. usage similar_text(string1,string2,percent) case […]