Pass Parameters to a VB Script to copy file

I have a batch file to copy files to the local desktop path that I call from my application (MAS200)....but the batch can't pass results back to the user.  So, can someone give me a VB Script that I can pass parameters ie., ....

VBScriptName.vbs <PathToSourcefile> <DestinationPath>

I want to give the user a MsgBox indicating the copy results.

Thanks
Craig

oceansupportAsked:
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.

sr75Commented:
Here you go:
strfile = "C:\sometextfile.txt"
 
set objFSO = CreateObject("Scripting.FileSystemObject")
set rFile = objFSO.OpenTextFile(strFile)
Do until rFile.AtEndOfStream
	rLine = rFile.ReadLine
	If rLine <>"" then
		results = results & rLine
	End If
End
 
rFile.close
wscript.echo results

Open in new window

0
sr75Commented:
whoops!!  should be a DO....LOOP  not a  DO....END
0
oceansupportAuthor Commented:
Will this work with this concept?
CopyScript.vbs <Sourcepath> <destinationpath>

Thanks
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

sr75Commented:
No it will not and I am not sure that you can pass parameters to a vbscript, but you can create a vbscript and run it from within a dos batch script.  So you can pass the parameters at the time of creation.  Just use the script I have provided you as a template of what to have your batch script create.
0
RobSampsonCommented:
Hi, you can run the following like this:

wscript test.vbs /Source:"C:\dsk.txt" /Destination:"C:\Temp\Temp\Test Script"

and this is the code in test.vbs

'=================
If WScript.Arguments.Count <> 2 Then
      MsgBox "You must pass two arguments to this script." & VbCrLf & _
            "Usage: wscript.exe CopyFile.vbs /Source:""<sourcepath>"" /Destination:""<destinationpath>""", vbOKOnly, "Error"
      WScript.Quit
End If
strSource = WScript.Arguments.Named("Source")
strDestination = WScript.Arguments.Named("Destination")
If Right(strDesination, 1) <> "\" Then strDestination = strDestination & "\"

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strSource) = False Then
      MsgBox "Could not find source file: " & strSource, vbOKOnly, "Error"
      WScript.Quit
End If
If objFSO.FolderExists(strDestination) = False Then
      MsgBox "Could not find destination folder: " & strDestination, vbOKOnly, "Error"
      WScript.Quit
End If
On Error Resume Next
objFSO.CopyFile strSource, strDestination, True
If Err.Number = 0 Then
      On Error GoTo 0
      MsgBox "File copied successfully.", vbOKOnly, "Success"
Else
      Err.Clear
      On Error GoTo 0
      MsgBox "File copy failed.", vbOKOnly, "Error"
End If
'=================

Regards,

Rob.
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
oceansupportAuthor Commented:
Thank you!!!!
0
RobSampsonCommented:
No problem.  Thanks for the grade.

Regards,

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.