How to run a command from the OK button in VB script?

This should be an easy one for all you programmers.

Ho do I create a dialogue box in VB script that when the users click OK, runs a command (copy the contents of a folder to their local machine) but if they click cancel the script ends?
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.

TimCotteeHead of Software ServicesCommented:
Hi wmcdade,

If Msgbox("Do you want to copy these files", vbYesNo) = vbYes Then
    'Copy the files
    'Don't copy them
End If

Tim Cottee

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
Hello wmcdade,

you could do something like
        If MsgBox("Do you want to run the copy action?", 1) = 1 Then
          'Run Command
        End If

MsgBox("Do you want to run the copy action?", 1) the 1 here means vbOkCancelButton
= 1 the 1 here means vbOk

so you run the command if someone clicks ok

hope this helps a bit
i assumed that the vb constants couldn't be used outright in vbs
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

TimCotteeHead of Software ServicesCommented:

No you can use them quite happily.

wmcdadeAuthor Commented:

Thanks, that was exactly what I needed.
:) thanks Tim
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

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.