-1

My VBScript is running in system account I need a Confirmation Message Box With Yes/no option to popup and be visible to user. I am able to display the message box using this command

ObjShell.run  "cmd.exe /C "" MSG * /SERVER:"  &IP& " " &Str_Message &""&""""

but I need yes and no confirmation box and fetch user Choice there.

user692942
  • 16,398
  • 7
  • 76
  • 175
AA29
  • 1
  • 7
  • Check inputbox function http://w3schools.sinsixx.com/vbscript/func_inputbox.asp.htm – JoSerra Apr 26 '18 at 10:48
  • 1
    Use [`MsgBox`](https://ss64.com/vb/msgbox.html) if you are just looking for user to press a button. – Pankaj Jaju Apr 26 '18 at 13:59
  • 1
    Possible duplicate of [How can I show a message box with two buttons?](https://stackoverflow.com/questions/3062401/how-can-i-show-a-message-box-with-two-buttons) – user692942 Apr 26 '18 at 18:11

1 Answers1

-1

Here is the documentation on the MsgBox function.

Here's an example of that code. These constants are built into vbscript, so you don't need to declare them. The vbSystemModal value will cause the message box to be "modal" - as in, it will appear on top of all other windows until it is dismissed.

userInput = MsgBox("Prompt",vbExclamation+vbYesNo+vbSystemModal,"Title")
Select Case userInput
    Case vbYes 
        MsgBox "User pressed yes."
    Case vbNo
        MsgBox "User pressed no."
End Select 

Note that you might want to be careful with an unexpected popup to end users, especially as it relates to which button is default and if the dialog is modal. If a user is typing and they hit spacebar when the box pops up, they might select the default button without reading the message first. You might consider the vbDefaultButton1 or vbDefaultButton2 values to assign a default button.

user692942
  • 16,398
  • 7
  • 76
  • 175
langstrom
  • 1,652
  • 11
  • 14
  • Instead of answering questions for a language that is over 20 years old, you could flag the question as a duplicate for something that in 20 years has surely been asked before. – user692942 Apr 26 '18 at 18:28
  • While we're at it, let's go ahead and ask the stackoverflow admins to prevent any new vbscript questions from being posted since every conceivable question that could possibly have been asked "has surely been asked before." That would be much better than actually posting a useful answer. – langstrom Apr 26 '18 at 18:31
  • @langstorm that wouldn't be true though. If someone has a clear problem and shown they've made an effort to solve it themselves, then that would be a perfectly acceptable question. But someone asking how to show two buttons in a message box doesn't fit into that category does it? – user692942 Apr 26 '18 at 18:35