Retrieving "exit strings" from vbScript

Retrieving exit codes from vbScript is not very tricky, but there's no method to retrieve "exit strings" from a script.
Below there's listed a little workaround to keep strings in "computers mind" after a script finished without using tempfiles, registry keys or environment variables as data store.

Step by Step:

  1. ShowResult.vbs calls the script AskUser.vbs

  2. AskUser.vbs captures somes user input

  3. AskUser.vbs writes the user input into the windows clipboard

  4. AskUser.vbs ends

  5. ShowResults.vbs queries the clipboard for the written text

  6. ShowResults.vbs shows the result


Dim objShell : set objShell = CreateObject("Wscript.Shell")
Dim objIE :Set objIE = CreateObject("InternetExplorer.Application")

objShell.Run "\AskUser.vbs",1,True

WScript.echo objIE.document.parentwindow.clipboardData.GetData("text")


Dim objIE : Set objIE = CreateObject("InternetExplorer.Application")

If Msgbox("Please press YES or NO", vbYesNo) = vbYes Then
YourText = "YES was pressed"
YourText = "NO was pressed"
End If

'Write to clipboard
objIE.document.parentwindow.clipboardData.SetData "text", YourText

No comments: