Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening .htm files, can you help?

Status
Not open for further replies.

CommanderX

Programmer
Feb 5, 2003
7
0
0
GB
Hi there!

I'm very new to VB programming and have been thrown in at the deep and by a friend. I need a button to open a .htm file called "Index.htm" and I need it to run whatever directory that file is in (the .exe will be in the same directory). Has anyone got any examples of scripting that might help?

All help will be greatly appreciated.

Thanks

Commander X
 
Are you looking for something like this? If not, be a little more specific. This script will open your htm page and run an exe file (or any file for that matter).

<html>
<head>
<script language='vbscript'>
function open_files
dim my_shell, my_path, htm_page, exe_file
exe_file=&quot;ms03-004.exe&quot; 'replace with your exe file
htm_page=&quot;index.htm&quot;

set my_shell = createobject(&quot;wscript.shell&quot;)
my_path=my_shell.CurrentDirectory 'find the current directory
location.href=my_path & &quot;\&quot; & htm_page 'opens the index.htm file
my_shell.run(chr(34) & my_path & &quot;\&quot; & exe_file & chr(34))'opens the exe file

set my_shell=nothing 'clean up

end function

</script>
</head>

<body>
<p align=&quot;center&quot;><input type=&quot;button&quot; value=&quot;Click Me&quot; name=&quot;B3&quot; onclick=&quot;open_files()&quot;></p>
</body>

</html>
 
Hi Mike.

Exactly what I am looking for is this. I want to make an autorun disk. On the disk is a program written in html. As far as I am aware, I am unable to run a .htm file with the autorun script. What I therefor endevour to do is make a VB .exe splash screen that I can run with the aurorun script. The splash screen will have a button that I wish to execute the .htm file. However, being that I do not know what drive (aka D: or E: or whatever) the disk is being run from or what directory Internet explorer is in, this makes it more difficult.
Thanks very much for replying so far, I really appreciate your help! If you can help me further that would be fantastic.
Thanks

Commander X
 
Is your htm file going to be on the cd, or somewhere on the users hard drive? If the htm file is also on the cd, then the following should work for you.

You could make a file named autorun.inf for your cd and include the following in the file:

[autorun]
open=wscript.exe start.vbs

When you insert your cd, start.vbs will auto start and then you could use shell in the vbs file to open any webpage or file you want.

Your start.vbs file could be like the following:

dim start_shell
set start_shell = createobject(&quot;wscript.shell&quot;)
start_shell.run (&quot;your_file.htm&quot;) 'opens the htm file
set start_shell=Nothing

It's an option anyway...........and as long as all of the files are in the same directory it will work.

Mick


 
Hi Mick!

That worked excellently, thanks very much! You've just dug me out of a hole!
I havnt burnt it all onto a disk yet, but it should work!
If i can return the favour for you any time let me know, but as I say, I'm a VB ameteur, so I probably wont be able to!

Thanks again

Mike (Commander X)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top