views:

1155

answers:

3
+2  Q: 

Prompt dialog ??

How to open a prompt dialog box in WSH usig JSacript??

The only pop-up dialog I've found in the doc is the WshShell.Popup() method. But I need a way to request the user to enter a string, like the window.prompt() method in DOM.

Thanks.

+5  A: 

I think the WScript object does not provide such a method however you can show an input box from vbscript running on WSH. So here is one possible solution which lets you call that VB function from within JS! Please note the file extension for the following code fragment ".wsf".

<!-- Test.wsf -->
<job id="InputBoxInJS">
   <script language="VBScript">
      Function VBInputBox(promptText)
        VBInputBox = InputBox(promptText)
      End Function
   </script>

   <script language="JScript">
      WScript.Echo("Hello from JScript")
      var x = VBInputBox("Enter text")
      WScript.Echo(x)
   </script>
</job>
SDX2000
Thanks.This should not depend on the language you use though, but on the environment where you are using the language.This looks like a bad design issue.Just a thought.
GetFree
A: 

There is also WshShell.Popup, which is accessible from VBScript and JScript. It also seems quite a bit more flexible than VBScript's built-in stuff.

David
WshShell.Popup displays a message box, not an input box like the OP needs. And the question says that WshShell.Popup won't do.
Helen
Ooh, my bad. Sorry about that.
David
A: 

My suggestion doesn't work.

trlkly