• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

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?
0
wmcdade
Asked:
wmcdade
  • 3
  • 2
1 Solution
 
TimCotteeCommented:
Hi wmcdade,

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



Tim Cottee
0
 
bruintjeCommented:
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
bruintje
0
 
bruintjeCommented:
i assumed that the vb constants couldn't be used outright in vbs
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
TimCotteeCommented:
bruintje,

No you can use them quite happily.

Tim
0
 
wmcdadeAuthor Commented:
Tim,

Thanks, that was exactly what I needed.
0
 
bruintjeCommented:
:) thanks Tim
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now