VBS code to copy file in all physical drives
Solved/Closed
Hello everyone,
Is there any code in VBScript that I can use to copy a file(s) in all physical drives at once without giving the driveletter(in a single line or two)?
The problem is that I couldnot find any VBS code that I could use to copy a single file to all physical drives & removable drives in a single line/sentence(s). I don't know much about VBS and I donot use any VB6/VB.net and I don't want to learn those VB6 or VB.net anyway.
Well, if you have any such code in batch also, please do mention it. If anyone knows the code, please explain in detail.
I do know about how to copy file in drives one by one (in VBS) but I don't know how to do it all at once in 1 line code.
Thanks everyone
Is there any code in VBScript that I can use to copy a file(s) in all physical drives at once without giving the driveletter(in a single line or two)?
The problem is that I couldnot find any VBS code that I could use to copy a single file to all physical drives & removable drives in a single line/sentence(s). I don't know much about VBS and I donot use any VB6/VB.net and I don't want to learn those VB6 or VB.net anyway.
Well, if you have any such code in batch also, please do mention it. If anyone knows the code, please explain in detail.
I do know about how to copy file in drives one by one (in VBS) but I don't know how to do it all at once in 1 line code.
Thanks everyone
Related:
- Vbs copy file
- Windows 10 iso file download 64-bit - Download - Windows
- Dvi file - Guide
- Messenger file downloader - Guide
- Kali linux iso file download - Download - Linux
- Super mario 64 file - Download - Platform
1 response
Exactly 5 hours earlier, I asked this very question and pasted it on this forum. But, I have discovered it myself using IsReady is the answer. The code would be
' This Sample copies the vbs file to all the existing drives.
' This sample gives an error "File already exists" since it finds a copy of itself already present in 1 of drives
' Using seperate name for duplicate copy prevents the error
' overwrite code maynot be working
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
For Each objDrive in colDrives
If objDrive.IsReady = True Then
objfso.CopyFile "filename.vbs" , objDrive.DriveLetter+":\" , overwriting = true
End If
Next
' This Sample copies the vbs file to all the existing drives.
' This sample gives an error "File already exists" since it finds a copy of itself already present in 1 of drives
' Using seperate name for duplicate copy prevents the error
' overwrite code maynot be working
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
For Each objDrive in colDrives
If objDrive.IsReady = True Then
objfso.CopyFile "filename.vbs" , objDrive.DriveLetter+":\" , overwriting = true
End If
Next
Jun 25, 2010 at 08:02 AM
Jun 26, 2010 at 09:04 AM
Jun 26, 2010 at 09:25 AM
But what I thought was that it could be a small help for someone (beginner) like me, trying to actually find some code.
Anyway, thank you for your comment ...
Jun 29, 2010 at 06:52 AM
' copy in flash drive
Const Removable = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = FSO.Drives
For Each Drive in colDrives
If Drive.DriveType = Removable then
fso.copyfile "new.vbs" , Drive.DriveLetter&":\"
End if
Next
Use it with const fixed = 2 & one can get file copied to all fixed drives