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:
- ShowResult.vbs calls the script AskUser.vbs
- AskUser.vbs captures somes user input
- AskUser.vbs writes the user input into the windows clipboard
- AskUser.vbs ends
- ShowResults.vbs queries the clipboard for the written text
- ShowResults.vbs shows the result
ShowResult.vbs
Dim objShell : set objShell = CreateObject("Wscript.Shell")
Dim objIE :Set objIE = CreateObject("InternetExplorer.Application")
objShell.Run "\AskUser.vbs",1,True
objIE.Navigate("about:blank")
WScript.echo objIE.document.parentwindow.clipboardData.GetData("text")
AskUser.vbs
Dim objIE : Set objIE = CreateObject("InternetExplorer.Application")
If Msgbox("Please press YES or NO", vbYesNo) = vbYes Then
YourText = "YES was pressed"
Else
YourText = "NO was pressed"
End If
'Write to clipboard
objIE.Navigate("about:blank")
objIE.document.parentwindow.clipboardData.SetData "text", YourText
No comments:
Post a Comment