VBScript to determine drive letter, copy all files and folder and show a progress bar

I am looking for some VBScript that will be run from a USB memory stick.

Its first job is to discover what the drive letter of the USB memory stick is. The script will be copied to several different makes of USB drives so it cannot be determined by make/model, etc.

The second job it to copy all the files and folders within 1 directory on the USB memory stick to a location on the host PC.
Copy X:\Builds\Build1 C:\Temp\Build1
(where X = the discovered drive letter)

The third job is to show an accurate progress bar during the copying.

Thanks
LVL 2
fruitloopyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CashpandaCommented:
You can set static drive letters for removable devices such as a USB drive in Computer Management under Storage > Disk Management.

You can use modified VBS file/folder copy script tailored to that drive letter.
I would start here with a template:
computerperformance.co.uk

You could set this script to run as a scheduled task, or manually run it as needed.

As for a detailed progress bar, it does not exist in windows.
We all want it. Microsoft refuses to deliver.
0
Bill PrewCommented:
Can you be more specific about what files will need to be copied to the host PC?  Are they all in one folder, are there subfolders, is it a list of files, etc?

~bp
0
RobSampsonCommented:
Hi, with this script located in the X:\Builds folder, this should copy the X:\Builds\Build1 folder to the C:\Temp folder on the computer you run it on.

The script uses a relative path to the the current folder of the script to find the Build1 folder on the USB drive.

Regards,

Rob.

strSourceFolder = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "Build1\"
strTargetFolder = "C:\Temp\"

If Right(strSourceFolder, 1) <> "\" Then strSourceFolder = strSourceFolder & "\"
If Right(strTargetFolder, 1) <> "\" Then strTargetFolder = strTargetFolder & "\"

Const FOF_CREATEPROGRESSDLG = &H10&
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strSourceFolder)

Set objShellApp = CreateObject("Shell.Application")
Set objFolder = objShellApp.NameSpace(strTargetFolder)

If Not objFolder Is Nothing Then
	'MsgBox "Copying " & objFile.Path & " to " & strTargetFolder
	objFolder.CopyHere strSourceFolder, FOF_CREATEPROGRESSDLG
Else
	WScript.Echo "There was an error finding " & strTargetFolder
End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fruitloopyAuthor Commented:
Thanks Rob, that works great.
0
RobSampsonCommented:
No problem. Thanks for the grade.

Rob.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.