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

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

问题描述

我有10个.vbs文件并将它们合并到一个.vbs文件中,即Main.vbs.Now如果我双击main.vbs,我的脚本开始运行。但我正在寻找可以从网络浏览器运行.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 Explorer,但是您必须保持较低的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:\temp\test.vbs"></script>

和test.vbs

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

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

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

这里是一个例子使用.hta文件,保存为例如test.hta,alwyas在使用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:\temp\output.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:\temp\test.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天全站免登陆