...

View Full Version : Launch a system based program from a web page.



KXM
10-18-2003, 07:39 AM
I think this is fairly simple...

I have creater a custom desk top, using a simple HTML doc.

I would like to be able to launce any program on my HD from it.
I know I can't just link to it, [this causes Windows to diplay a blank page as my desktop] and if I open it in a browser, it treats it like a download. [IE: save? ope? cancle?]

Is there a simple way to make a Java script to just launch a program?

TIA!!!

Philip M
10-18-2003, 07:42 AM
No. There is no way that JavaScript can launch a program, thank the Good Lord!

KXM
10-18-2003, 07:46 AM
I had a feeling... And I agree VERY much... Save this one instance. :(

THNX for the prompt responce. Any hints as to other options?

swmr
10-18-2003, 07:18 PM
I looked into this sort of thing, a while back, and found that Internet Explorer can utilize the ShellExecute Method (http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/objects/ishelldispatch2/shellexecute.asp) for launching applications (http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/launch.asp)

Here's an example that requires an absolute path to each program (though this can be substituted a couple of ways):

<html>
<head>
<title>-</title>

<script type="text/JScript">

function Launch(){

var v;

v = new ActiveXObject("Shell.Application");

v.ShellExecute("some-file-name.exe", "", "C:\\some-folder\\a-subfolder", "open", 10);}

</script>

</head>
<body>
<button onclick="Launch()">program link</button> - (needs real file-names...)
</body>
</html>

(The link to 'ShellExecute' [above] explains each of the parameters.)

Something that might be easier (if your links are for programs that have desktop shortcuts) involves using the ssfDESKTOP constant of "0" (in place of an absolute path to each program's location), and the inclusion of only the name of a shortcut (instead of some-file-name.exe):

v.ShellExecute("shortcut-name", "", 0, "open", 10);

Another possible set up (perhaps the simplest, syntax-wise) is to copy your program shortcuts into the "windows", "system", or "system32" folder(s):
Here you won't need to specify anything but the shortcut name (unless there's reason to 'recommend' a window size other than the program default):

v.ShellExecute("shortcut-name");

If you don't know (off-hand) where the official "system folder" is located, you can use its ShellSpecialFolderConstant (http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/objects/shell/shellspecialfolderconstants.asp) value of 37 to open it, like so:

<html>
<head><title>-</title>
<script type="text/JScript">
function SysFold(){
var v;
v = new ActiveXObject("Shell.Application");
v.Open(37);}
</script>
</head>
<body>
<button onclick="SysFold()">system folder</button>
</body>
</html>

The real point, though, is that the ShellExecute Method shouldn't trip a dialog-box whenever you choose to launch a program from IE.

Where Shell scripting is involved, it seems that we only have to confirm such operations (in each document) once -- and the message-box for this reads something like:

"The file or folder you are opening contains Web content that may be unsafe. The Web content has either been modified or is from an unknown source. Do you want to allow it to be initialized and be accessed by scripts?"

After choosing "Yes", you should not be asked again -- even when the document is closed & reopened (that is, unless its code has since been modified).


The less important idea was that using shortcuts can reduce the syntax required for writing links to programs (and actually, the same thing can be done for any application located in the system folder(s) -- such as Notepad or MSpaint: no path or file extension is required...):

<html>
<head>
<title>-</title>

<script type="text/JScript">

var v = new ActiveXObject("Shell.Application");

</script>

</head>
<body>
<p>
<a href="javascript&#58;v.ShellExecute('some-file-name.exe', '', 'C:\\some-folder\\a-subfolder');">regular link (fake)</a>
</p>
<p>
<a href="javascript&#58;v.ShellExecute('shortcut-name');">shortcut link (fake)</a>
</p>
<a href="javascript&#58;v.ShellExecute('Notepad');">link to Notepad.exe - in the system folder (if you have it there)</a>
</body>
</html>

If none of this stuff works for you, there's another thread (http://codingforums.com/showthread.php?threadid=16467) around here that's related to your topic (& has a lot of good information, regardless...).

KXM
10-20-2003, 11:05 AM
This works flawlessly!!!!! I can't thank you enough!!!!!


THNX!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum