VBS code to copy file in all physical drives
Solved/Closed
Related:
- Vbs copy file
- Windows 10 iso file download 64-bit - Download - Windows
- Kmspico zip file download - Download - Other
- Dvi file - Guide
- Messenger file downloader - Guide
- Tiny 11 iso file download - Download - Windows
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