문제

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!

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top