Dim oFSO, oDrive, objFolder, oDestination, shell
Const USBDRIVE=1
oDestination = "c:test"
set oFSO = Wscript.CreateObject("Scripting.FileSystemObject")
Set shell=createobject("wscript.shell")
For Each oDrive in oFSO.Drives
If oDrive.DriveType = USBDRIVE And oDrive.DriveLetter <> "A" Then
shell.run oDrive.DriveLetter & ":batch.bat"
set shell=nothing
End If
Next
Sub CopyFiles(oPath, oDst)
Set objFolder = oFSO.GetFolder(oPath)
For Each Files In objFolder.Files
WScript.Echo "Copying File",Files
newDst=oDst&""&Files.Name
oFSO.CopyFile Files,newDst,True
WScript.Echo Err.Description
Next
End Sub
I watched everything what you did,and when I putted the USB into the PC, Command Prompt Pop Up, and inside it it says: F:\>\usb.vbs and Windows Script Host also Pops Up saying:
Script: F:\USB.VBS
Line: 3
Char:16
Error: Invalid character
Code: 800A0408
Source: Microsoft VBScript compilation errorÂ
Obviously you have an infavlid character on line 3. Make sure that you don't have any extra spaces or characters that aren't accepted in vb scripting. If you have no idea what I just said, then you probably shouldn't be doing this project.
Obviously you have an infavlid character on line 3. Make sure that you don't have any extra spaces or characters that aren't accepted in vb scripting. If you have no idea what I just said, then you probably shouldn't be doing this project.
Â
Seriously….. This is supposed to be a help thread. Have some love and help him out.
Â
@ Antonio Montana -Â
I had the same problem and it took me some time to figure it out. Its the stupid quotation marks that are not being recognized
because of the font from this forum. Just go through the script erasing every " character and retyping it. That should do the trick.
Error:Â Â Â Â Â The system cannot find the file specified.
Cade:Â Â Â Â Â 80070002
Source:Â Â (null)
Â
Here is Line 10 from USB.VBS:
shell.run oDrive.DriveLetter & ":batch.bat"
Â
Here is Line 10 from your script:
shell.run oDrive.DriveLetter & “:batch.batâ€
Â
Any help would be great.
Thanks,
DaUltimate1
Â
UPDATE:
Ok after some "tinkering" I figured out why it was not seeing batch.bat
Thats because I have a HP printer with SD card reader conected and the computer recognizes that SD card reader inside the printer as a removable drive.
So when the U3 is activated, the script tells it to go down the list and find the "Removable Drive/USB." In my case the first one is the SD card reader and it gives me the error.
To avoid this in the future there needs to be an if else type of statement in the script to search for other USB devices and look for the batch.bat file there before executing it.
Obviously you have an infavlid character on line 3. Make sure that you don't have any extra spaces or characters that aren't accepted in vb scripting. If you have no idea what I just said, then you probably shouldn't be doing this project.
Â
Seriously….. This is supposed to be a help thread. Have some love and help him out.
Â
Â
I understand asking for help, but admin did help, and like he said, if you don't even know what vb scripting means or what an invalid character is, then you really should not be leaping straight into auto-hacking USB projects. Start with something a little more basic. Please note that I am not telling you to do something more basic, you seem to know what you're doing. But there are a lot of people on this site and others that try really high-level projects, higher than this one, with no coding background, and that's just not a good idea.
follow me!