MSGBOX with Yes No buttons that return an exit code.
Updated: 17 Jun 2010
I had been tasked with rolling out XP SP3. The actual install was easy enough, but I had to come up with a message box at the start that gave them the option to say No to running it now.
The problem was that with my very basic knowledge of vbscript I could only create a msgbox that no matter what button I pressed, it reported back a 0 to say it had run properly.
After a few hours googling, I found this script which output a code of 100 for Yes and 200 for No.
So I just thought I would share it with everyone...
Dim objShell, intReturn
Set objShell = CreateObject("Wscript.Shell")
intReturn = objShell.Popup("Do you see this ""Hello World""?",4,"Hello World", 4+32)
If intReturn = 6 Then
MsgBox "yes, exit code 100"
WScript.Quit(100)
Else
MsgBox "no, exit code 200"
WScript.Quit(200)
End If
If intReturn = 6 Then
MsgBox "yes, exit code 100"
WScript.Quit(100)
Else
MsgBox "no, exit code 200"
WScript.Quit(200)
End If
Blog Entry Filed Under:
Group Ownership:
The Endpoint Management Community Blog is the perfect place to share short, timely insights including product tips, news and other information relevant to the Endpoint Management community. Any authenticated Connect member can contribute to this blog.