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

I have a 10.vbs file and included them in a single .vbs file, namely Main.vbs.Now, if I double-click on main.vbs, my script started working. But can I still run the .vbs file from a web browser? So no one should go to the directory where Main.vbs is stored and double-click on it.

My Main.VBS content:

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 
+4
source share
3 answers

Yes, if you use Internet Exlorer, but you will need to maintain low IE security settings to run it, and even then you may be asked for confirmation. It all depends on which version and Windows SP, which security updates, which version of IE and what settings in IE.

I suggest taking a look at why you will start a local script this way. You can easily create and distribute a shortcut that runs your script without any configuration or hint problems.

Ik you need a user interface in which you can use the built-in VBScript, or you could use the .HTA file instead of the .html or .asp file, security is less associated 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 requests, and when I confirm, I get output.txt in c: \ temp

And the last example here is an .hta file, save it, for example, test.hta, also 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> 
+6
source

You can open the classic ASP page that includes your script files, execute them and report the 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
source

For the purposes of VBSlover, the best way would be to program an HTML application (there is no need for additional web server complexity, no security problems as in a regular .html script client). Of course, just wrapping HTML code around existing VBScript code would be fatal, you would need to develop a useful graphical interface and distribute existing functions into suitable event handlers. Definitely, this is not a project that can be solved by publishing many questions here - some thorough research is an important necessary starting point / preliminary version.

0
source

All Articles