I would like to open an application from a hyperlink on a webpage.
1. the webpage is located on my local machine.
2. the application is located on my local machine.
3. the application will run on my local machine.
In other words... The WEB is really not involved.
What I have so far works with a Netscape Browser but what I really
need is for it to work in the IE browser or one that I will create
using
VB.net.
The code I have so far uses JAVAscript and some simple HTML code.
The code is as follows:
<html>
<head>
<title>Application launcher</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">
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, args) {
if ((typeof path == 'string') && (path != '')) {
if ((Shell.MSIE) && (typeof Shell.$ == 'undefined')) {
/* If first time, try to instantiate ActiveX object
* for shell access:
*/
try {
Shell.$ = new ActiveXObject('WScript.Shell');
}
catch(e) {
Shell.$err(e.message);
return null;
}
}
/*
*/
if (Shell.MSIE) {
var arg = ((typeof args == 'string') && (args != '')) ?
(' "' + args + '"') : '';
var exe = '"'.concat(path, '"', arg);
try {
Shell.$.Run(exe);
}
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) ;
Shell.$.initWithPath(path);
if ((typeof args == 'string') && (args != '')) {
Shell._ = Components.classes['@mozilla.org/process/util;1'].
createInstance(Components.interfaces.nsIProcess);
Shell._.init(Shell.$);
Shell._.run(false, [args], 1);
}
else {
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:\\windows\\note pad.exe', 'c:\
\netlog.txt'));">launch Notepad with netlog.txt</a><br>
<a href="javascript:void(Shell.run('c:\\windows\\note pad.exe', 'c:\
\myfile.txt'));">launch Notepad with myfile.txt</a><br>
</p>
</body>
</html>
I know I have some syntax problems but I am really stumped as to
where.
Any help would be appreciated.
Kevin