Question

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!

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top