1

いくつかの引数 (名前、電子メールなど) を受け取る VBScript があり、HTML フォームを作成しました。

ユーザーがデータを入力したら、VBScript を実行し、フォーム データをパラメーターとして渡します。

問題は、HTML フォームから VBScript を実行する方法です (サーバーがないため、クライアントは HTML を実行し、マシン上で VBscript を実行します)。

VBScript は外部ファイルです。それを myScript.vbs と呼びましょう

4

3 に答える 3

1

サーバーへの HTTP 接続なしで HTML フォームがデータを「送信」する方法を知りません。問題を解決できる可能性のあるいくつかのオプションを次に示します。

  1. VBScript は基本的にClassic ASPと同じものです。Windows 7 で IIS をホストし、Web ブラウザーで "localhost" を指定することもできます。
  2. フォームを変更して、VBScript タスクの実行をトリガーするActiveX コントロールまたはその他のブラウザーセーフではない実行可能ファイルを含めることができます。
  3. Internet Explorerを組み込み、ユーザーが送信をクリックしたときにタスクをトリガーするスタンドアロン プログラムを作成できます。

お役に立てれば!

于 2012-08-01T14:49:53.107 に答える
1

偶然にも、昨日、Ruby でこれを行う方法についての質問を公開し、サンプルとして vbscript スクリプトを提供したので、ここにあります。しかし実際には、スクリプトからブラウザを起動するのが最善です。

Set web = CreateObject("InternetExplorer.Application") 
If web Is Nothing Then 
  msgbox("Error while loading Internet Explorer") 
  Wscript.Quit 
Else 
  with web 
    .Width = 300 
    .Height = 175 
    .Offline = True 
    .AddressBar = False 
    .MenuBar = False 
    .StatusBar = False 
    .Silent = True 
    .ToolBar = False 
    .Navigate "about:blank" 
    .Visible = True 
  end with 
End If 

'Wait for the browser to navigate to nowhere 
Do While web.Busy 
  Wscript.Sleep 100 
Loop 

'Wait for a good reference to the browser document 
Set doc = Nothing 
Do Until Not doc Is Nothing 
  Wscript.Sleep 100 
  Set doc = web.Document 
Loop 

'Write the HTML form 
doc.Write "Give me a name<br><form><input type=text name=name ><input type=button name=submit id=submit value='OK' onclick='javascript:submit.value=""Done""'></form>" 
Set oDoc = web.Document 
Do Until oDoc.Forms(0).elements("submit").Value <> "OK" 
  Wscript.Sleep 100 
  If web Is Nothing or Err.Number <> 0 Then 
    msgbox "Window closed" 
    Wscript.Quit 
  End If 
Loop 
name = oDoc.Forms(0).elements("name").value 
oDoc.close 
set oDoc = nothing 
web.quit 
set web = nothing 
Wscript.echo "Hello " & name 
于 2012-08-01T14:53:10.837 に答える
0

ここに私のHTMLコードがあります

<form id="myform">
<input type="radio" name="formradio" id="yes" />
<input type="radio" name="formradio" id="no" />
<select name="formemail" size="1">
<option value="someone@example.com" selected="selected">someone@example.com</option>
</select>
<button type="submit" id="sendReport">Send Status Report</button>

HTMLページ内の私のVBscriptコードは次のとおりです

<script language="VBScript" type="text/vbscript">
<![CDATA[
    Sub sendReport_onclick()
        'Logic to process the form goes in here.
        MsgBox myform.formradio.value
        MsgBox myform.formemail.value            
        'Run: wscript "{path}externalVBScript.vbs" "{path}"
        WSHShell.Run "wscript """ & Path & "externalVBScript.vbs"" """ & Path & """"
        window.status = "Script has been run via WScript"
    End Sub
]]>
</script>
于 2012-08-01T15:49:12.140 に答える