0

I would like to create a VBScript file that opens a msgbox that has the options "Yes or No" and maybe a question mark icon. I would like yes to open a specified path to a file, and no to end the program. I want the dialogue box to say: Would you like to eject the CD drive?... I have this code (cd eject) so don't need it. But I do need to figure out the code to create the message box ad to open the vbs script upon Yes. Any help would be greatly appreciated. Thanks!

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
drcomputer
  • 406
  • 2
  • 7
  • 15
  • Did you even try to do it yourself? All of this is easily found with a quick search here or on Google. – JustSomeQuickGuy Feb 12 '14 at 03:53
  • Yes I did. I tried the "GoTo" command, but it always ave me a runtime error, and when I tried using multiple lines (if the msgbox is 6 code &_ next line etc.) that didn't work, not did just putting the code all I one line with &s. – drcomputer Feb 12 '14 at 04:00

1 Answers1

2

I would suggest looking at the MsgBox function here. Also, information on the Run function. Both have examples showing what you're asking for.

If MsgBox("Would you like to eject the CD drive?", vbYesNo + vbQuestion) = vbYes Then
    'Code to eject the CD drive
    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run "C:\Path\To\File.exe" 'Run normal file
    objShell.Run "wscript.exe C:\Path\to\File.vbs" 'Run VBScript
End If
JustSomeQuickGuy
  • 933
  • 1
  • 10
  • 21