Is it possible to run the VBScript file(.vbs) from the browser?

后端 未结 3 1292
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-18 08:32

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 an

相关标签:
3条回答
  • 2020-12-18 08:47

    You can expose a classic ASP page that includes your script files, execute them and report results to the browser.

    Asp pages are served by IIS (depending on version you may need to configure ASP settings) and can be run from any browser.

    0 讨论(0)
  • 2020-12-18 08:55

    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.

    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.

    example: test.html

    <script type="text/vbscript" src="c:\temp\test.vbs"></script>
    

    and 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
    

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

    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>
    

    or

    <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>
    
    0 讨论(0)
  • 2020-12-18 09:08

    For VBSlover's purpose the best way would be to program a HTML Application (no need for the extra complexity of a web server, no security hassles as in a plain client .html script). Of course, just wrapping some HTML code around existing VBScript code would be fatal, you'll have to design a useful GUI and distribute the existing features into suitable event handlers. Definitely not a project that can be tackled by posting a barrage of questions here - some careful research of your own is a necessary starting point/pre-requisite.

    0 讨论(0)
提交回复
热议问题