Fredledingue Posted August 23, 2005 Posted August 23, 2005 Hi,I DON'T ASK how to insert a script in a webpage (I already moreless figured that out).What I would like to know is how to run a script that is not in the webpage but in a separate file (inthis case a .vbs file), by clicking on a link or a button.Then how to open the htm file eventualy created by this script...Thanks
dman Posted August 23, 2005 Posted August 23, 2005 If you are trying to generate dynamic web pages with VB script you want to be looking at Active Server Pages (ASP).http://www.asptutorial.info/
Fredledingue Posted August 24, 2005 Author Posted August 24, 2005 Thanks, but that doesn't answer to my question at all.Thanks for the link anyway, I'll look at it.
dman Posted August 24, 2005 Posted August 24, 2005 OK, the answer to your question is you cannot execute content on the client from within a browser without using ActiveX or Java if that is what you are asking. You did not specify whether the vbs was on the client or server. A VBS on the server generating web pages is ASP. Exactly what are you trying to accomplish, It would help to have more detail in order to provide more appropriate answer.
Fredledingue Posted August 25, 2005 Author Posted August 25, 2005 VBS on client side.I'm trying to simply run a vbs file that I created myself and that is on the my computer, by clicking a link on the htm page that I also creted mysel and that is also in my computer, in the same directory as the vbs.The reasons why I don't want to include the script in the page are that it's more convenient for me to edit scripts and htm pages separately, and that scripts are quiet long, that in the page there are other links that are simple and other that may require other scripts etc..I would like also running the same script alone, from the vbs file, not in the htm file.
dman Posted August 26, 2005 Posted August 26, 2005 (edited) So the HTM page is a launcher for other scripts? And you are just clicking the htm file to run, not using a webserver?You CAN run external scripts with the src tag... Add src="<drive>:\<path>\file.vbs" in your <script> tag. There are limits on what you can run though, nothing that launches it's own windows will execute. Code that works with filesystem will prompt a warning but should execute OK. You should be able to run code that creates a htm page and then use ie.navigate "newpage.htm"to navigate to the new page. I have never seen anyone use a browser and scripts in quite this manner, but it should be possible.If you can make the script do what you want while embedded in the HTML file it will work equally well in external file referenced through src="<file>"here is simple external file code.test.html<HTML><HEAD><META HTTP-EQUIV="expires" CONTENT="0"><TITLE>Test External VBS</TITLE></HEAD><BODY>This is a external vbs script test...<FORM NAME="Form1"> <INPUT TYPE="Button" NAME="Button1" VALUE="Run"> <script FOR="Button1" EVENT="onClick" LANGUAGE="VBScript" src="test.vbs"></SCRIPT></FORM></BODY></HTML> test.vbsmsgbox "External Script test.vbs" Edited August 27, 2005 by dman
memorex Posted August 28, 2005 Posted August 28, 2005 Th reason that it isn't nearly as possible is, that it's the perfect way to integrate spyware, virusses and trojans.
Fredledingue Posted August 28, 2005 Author Posted August 28, 2005 Hi! Thanks a Gb, dman, that's what I was looking for! I realised that for launching a script-created webpage it's better to embed the script into the page and even that, was not obvious.But the code you gave me will be very useful for launching scripts that have nothing to do with htm page viewing, ironicaly...(I'm one of the very rare scripter who use scripts for other use than server or ntwork.)Because codes are long (more than 100 lines) I prefer to create a separate htm file with one script in it.I then came with this solution:<script LANGUAGE="VBScript"> <!-- sub window_onLoad() '-----script that generates an htm page source------- NewHtm = NewHtm & "<p>Hello World! " & Date & "</p>" '-----end of script---- Document.Body.InnerHTML = NewHtm end sub --> </SCRIPT>
dman Posted August 29, 2005 Posted August 29, 2005 Glad I could help Fred.You are right, script is useful for all kinds of desktop tasks. I usually do "scripting" tasks with simple visual foxpro programs (.prg files). VFP is perhaps the easiest and most powerful language ever created (you can tell I'm biased). VBS has great advantage though being preinstalled. You also might want to try making a .HTA interface for your script launcher. gunsmokingman has lots of nice examples of this type of code.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now