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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing an application on client side

Status
Not open for further replies.

thysonj

Programmer
Jul 6, 2001
240
US
I know cfexecute is strictly server side but I am searching for some way to execute a command-line command on the client side. I am not too familiar with Javascript...is there way with this? If not, has anyone faced a similar situation? What did you do? I am open to anything at this point.

Thanks
 
To make this more clear.
The application will already be installed on the client side. All I need to do is to initate it with some kind of action. Preferably I would like to be able to pass parameters which is why a command-line solution would be best.
 
Is this an application that you've written yourself? Or a commercial app?

Not that it matters, really. By their very nature, Java and Javascript have been designed to run in their own sandbox... and care has been taken to forbid them from interacting (ie - launching) with other apps (though, in true Microsoft fashion, they've circumvented this security feature in IE and provided the ActiveXObject... which can launch a limited set of applications - typically MS Office apps).

There are ways around it with Java... but, to be able to launch something on the client-side with Java, the user needs a true JRE running client-side as well.
Hope it helps,
-Carl
 
Using the WScript.Shell ActiveXObject, you could execute a command-line application on the client using JScript in your web page. Limitations are:[ul][li]The client must be running Windows and have the Windows Scripting Host installed (comes with Windows 2000 and later, I think)[/li][li]Depending on the security settings of the browser (specifically, the setting for "script ActiveXObjects not marked safe for scripting"), one of three things will happen:

[ol][li]the script will fail to run (if the setting is "disable");[/li][li]the user will be prompted that the web page is trying to access an ActiveXObject not marked safe for scripting, and will have to approve the action (if the setting is "prompt");[/li][li] or, the script may simply run as intented (if the setting is "enable")[/li][/ol][/li][/ul]Here's how you would launch Notepad:
Code:
  <script language=&quot;JScript&quot;>
     var sh = new ActiveXObject(&quot;WScript.Shell&quot;);
     sh.Exec(&quot;notepad.exe&quot;);
  </script>
See for more details.

Hope this was helpful,
-pcorreia
 
You also forgot that little requirement that it only works in IE.

[censored]

Hope it helps,
-Carl
 
Righto, Carl. Clearly, my solution is only viable if you are developing an internal application where you know the audience only uses a single browser on a limited set of OSes, and that single browser is IE and those OSes are Windows 2000 and above. A lot of ifs, I know.

But, that begs the question... if you're not developing an internal application, what are you doing trying to run an executable on the client? Most web surfers will consider that a heinous offense.

-pcorreia
 
> Most web surfers will consider that a heinous offense.

Ahhhh... good point, pcorreia!

Though... even the internal projects my company can't count on a single browser or platform. I envy those that can! ;)
Hope it helps,
-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top