Link to home
Start Free TrialLog in
Avatar of oceansupport
oceansupport

asked on

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

Avatar of sr75
sr75
Flag of United States of America image

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

whoops!!  should be a DO....LOOP  not a  DO....END
Avatar of oceansupport
oceansupport

ASKER

Will this work with this concept?
CopyScript.vbs <Sourcepath> <destinationpath>

Thanks
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.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you!!!!
No problem.  Thanks for the grade.

Regards,

Rob.