launch a program from html page

This is a discussion on "launch a program from html page" within the JavaScript Forum section. This forum, and the thread "launch a program from html page are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 22nd, 2007, 06:53
New Member
Join Date: Feb 2007
Location: uae
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
launch a program from html page

I need your help, can you !!!


I am trying to launch a program that residents in C drive (I mean that the path of the program will not change, it will be always the same) from html page. So that if the user clicks on the link, the program that is stored in the user's computer should start. I have tried to run programs with exe extension and another one with TBK extension. Below is the javascript code that I used. I got it from another forum.
<html>
<head>
<title>Exe</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">
/*
Copyright (c) 2005 VK [schools_ring_at_yahoo.com]
Permission is hereby granted, free of charge, to any person obtaining
a copy
of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without
limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or
sell copies of the Software, and to permit persons to whom the
Software is furnished
to do so, subject to the following conditions:</p>
The above copyright notice and this permission notice shall be
included in
all copies or substantial portions of the Software.</p>
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY
KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var Shell = {
'$err' : function(m) {
var msg = m || 'Security exception';
window.alert('[Shell] script object\n\n' + msg);
}
, 'MSIE' : ( (typeof window != 'undefined')
&& (typeof window.ActiveXObject != 'undefined'))
, 'Gecko' : ( (typeof window != 'undefined')
&& (typeof window.netscape != 'undefined')
&& (typeof window.netscape.security != 'undefined')
/* that Opera... always pretending to do everything
* everywhere but not really doing anything of it...
*/
&& (typeof window.opera != 'object'))
, 'run' : function(path) {
if ((typeof path == 'string') && (path != '')) {
if ((Shell.MSIE) && (typeof Shell.$ == 'undefined')) {
try {Shell.$ = new ActiveXObject('WScript.Shell');}
catch(e) {Shell.$err(e.message);}
}
if (Shell.MSIE) {
try {Shell.$.Run(path);}
catch(e) {Shell.$err(e.message);}
}
else if (Shell.Gecko) {
/* Netscape security model grants privileges
* on the per-call per-context basis; thus
* privilege request and privilege usage
* have to be in the same block.
*/
try {
netscape.security.PrivilegeManager.
enablePrivilege('UniversalXPConnect');
Shell.$ = Components.classes['@mozilla.org/file/local;1'].
createInstance(Components.interfaces.nsILocalFile) ;
/* NOTE: initWithPath has problems on MacOS and other OSes
* which do not represent file locations as paths.
* If you do use this function, be very aware of this problem!
*/
Shell.$.initWithPath(path);
Shell.$.launch();
}
catch(e) {
Shell.$err(e.message);
}
}
else {
Shell.$err('not supported on this platform');
}
}
else {
Shell.$err('Invalid argument');
}
}
};
</script>
</head>
<body>
<p>
<a
href="javascript:void(Shell.run('C:\\Program Files\\WinZip\\WINZIP32.EXE'));">Launch EXE</a>
</p>
</body>
</html>

I have used WinZip as an example.
Now, if I run this code locally from my machine it will run only exe program with IE, but not the TBK. However, Netscape will run the two types of the extension. Honestly, IE is more important to me. Another problem is that If I upload the page to server, neither IE nor Netscape are able to run the programs. Can anybody help me with that. Honestly, this is the first time I run JavaScript code!!!
Reply With Quote

Reply

Tags
launch program

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert HTML Page to PDF in ASP.net, C#.net Jagdish ASP.NET Forum 6 Jun 9th, 2007 08:02
Open xml in new html page kingfrank JavaScript Forum 3 Apr 4th, 2007 11:26
Ever try to make a web page launch local programs? Beansly Introduce Yourself 2 Apr 24th, 2006 14:14
What program to use and should I learn HTML? Rob Web Page Design 5 Apr 25th, 2005 14:01


All times are GMT. The time now is 19:16.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43