是否可以从浏览器运行 VBScript 文件 (.vbs)? [英] Is it possible to run the VBScript file(.vbs) from the browser?

查看:20
本文介绍了是否可以从浏览器运行 VBScript 文件 (.vbs)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 10 个 .vbs 文件,并将它们合并到一个 .vbs 文件中,即 Main.vbs.现在如果我双击 main.vbs,我的脚本就会开始运行.但我无论如何都在寻找可以从 Web 浏览器运行 .vbs 文件吗?这样就不用去Main.vbs所在的目录双击了.

I have 10 .vbs file and incorporated them into a single .vbs file namely Main.vbs.Now if I double click on the main.vbs,my script got started to run. But I am looking for anyway can I run the .vbs file from the web browser? So that no one need to go to the directory where the Main.vbs kept and double clicked on it.

我的 Main.VBS 内容:

My Main.VBS contents:

Dim oShell : Set oShell = WScript.CreateObject ("WScript.Shell")
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
oShell.CurrentDirectory = FSO.GetFile(Wscript.ScriptFullName).ParentFolder
oShell.run "A.VBS", 1, True
oShell.run "B.VBS", 1, True
oShell.run "C.VBS", 1, True
oShell.run "D.VBS", 1, True

推荐答案

是的,如果您使用 Internet Exlorer,您可以,但是您必须将 IE 安全设​​置保持在较低的水平才能运行它,即使这样您也会收到确认提示.一切都取决于 Windows 的哪个版本和 SP、哪些安全更新、哪个版本的 IE 以及 IE 中的哪些设置.

Yes you can if you use Internet Exlorer, but you will have to keep your IE security settings low to run it and even then you could have a prompt to confirm. All depends on which version and SP of Windows, which security updates , which version of IE and which settings in IE.

我建议再看看为什么要以这种方式启动本地脚本.您可以轻松制作和分发启动脚本的快捷方式,无需设置和提示.

I suggest taking a second look at why you would start a local script this way. You can easily make and distribute a shortcut that starts your script without hassle of settings and prompts.

我需要一个用户界面,您可以使用 Vbscript 内置文件,或者您可以使用 .HTA 文件而不是 .html 或 .asp 文件,这些文件的安全性问题不大.

Ik you need a User Interface you can use Vbscript build-in or you could use a .HTA file instead of a .html or .asp file, security is less an issue with these files.

示例:test.html

example: test.html

<script type="text/vbscript" src="c:	emp	est.vbs"></script>

和 test.vbs

Const ForReading = 1, ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")
Set writefile = fso.OpenTextFile("c:	empoutput.txt", ForWriting, True)
writefile.write "test"
writefile.close

当我加载 test.html 时,我得到两个提示,当我确认我在 c: emp 中得到 output.txt

When i load test.html i get two prompts and when i confirm i get the output.txt in c: emp

最后这里有一个.hta文件的例子,将其保存为例如test.hta,使用ActiveX或Vbscript时总是使用IE

And last here an example with a .hta file, save it as eg test.hta, alwyas use IE when using ActiveX or Vbscript

<HTML>
<HEAD>
<SCRIPT language="VBScript">
<!--
Const ForReading = 1, ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")
Set writefile = fso.OpenTextFile("c:	empoutput.txt", ForWriting, True)
writefile.write "test"
writefile.close
'-->
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>

<HTML>
<HEAD>
<script type="text/vbscript">
  sub test
    const runminimized = 7
    const dont_wait_for_end = false
    Set wshShell = CreateObject("WScript.Shell")
    WshShell.Run "c:	emp	est.vbs",runminimized, dont_wait_for_end
  end sub
</script>
</HEAD>
<BODY>
  these are the instructions
  <button onclick="vbscript:test" >Run the script</button>
</BODY>
</HTML>

这篇关于是否可以从浏览器运行 VBScript 文件 (.vbs)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆