From: Swifty on
I know that JavaScript goes out of its way to make it impossible for
local commands to be executed, but in a situation where I own
everything; the server, the webpage, the local system, the browser
(and anything else that you can think of), is there a way to execute a
local command?

To give you the specifics: The webpage is the source control for all
the HTML and CGI scripts on our department server (remote from me/my
PC). After I've checked out the file that I want to work on, it would
be nice if that file could be opened on my local system. To do this,
the JavaScript running on my local system would have to execute a
command such as:

"C:\Program Fies\Editor\Edit.exe" "L:\path\to\file\filename"

I realise that I'll probably have to make some adjustments to my
browser to accommodate this, but I prefer to keep these to a minimum,
as I use all sorts of different browsers, and I'd never be certain
which one I'd be using.

If it helps, I could easily create a CGI script to run under apache on
my local system, and that could be used as the mechanism that actually
issues the host command. So the JavaScript running on my local PC
could issue some sort of httprequest to my local apache to cause the
editor to launch.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
From: purcaholic on
On 7 Apr., 10:45, Swifty <steve.j.sw...(a)gmail.com> wrote:
> I know that JavaScript goes out of its way to make it impossible for
> local commands to be executed, but in a situation where I own
> everything; the server, the webpage, the local system, the browser
> (and anything else that you can think of), is there a way to execute a
> local command?
>
> To give you the specifics: The webpage is the source control for all
> the HTML and CGI scripts on our department server (remote from me/my
> PC). After I've checked out the file that I want to work on, it would
> be nice if that file could be opened on my local system. To do this,
> the JavaScript running on my local system would have to execute a
> command such as:
>
> "C:\Program Fies\Editor\Edit.exe" "L:\path\to\file\filename"
>
> I realise that I'll probably have to make some adjustments to my
> browser to accommodate this, but I prefer to keep these to a minimum,
> as I use all sorts of different browsers, and I'd never be certain
> which one I'd be using.
>
> If it helps, I could easily create a CGI script to run under apache on
> my local system, and that could be used as the mechanism that actually
> issues the host command. So the JavaScript running on my local PC
> could issue some sort of httprequest to my local apache to cause the
> editor to launch.
>
> --
> Steve Swifthttp://www.swiftys.org.uk/swifty.htmlhttp://www.ringers.org.uk

Hi Steve,

running a system process from a JavaScript within a webpage won't be
possible due to security reasons.

You can use a Java applet, or a Silverlight app to do this. There is
also another way to do this with vbs/wsh if you are using a IE and if
the security settings of your browser/system allow it.

Following vbs example added to a webpage should work in ie:

[code]
<input type="button" name="vbsExample" value="Run me" language="vbs"
onclick="runEditor" />
<script language="vbs">
Sub runEditor
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "notepad.exe C:\path\to\textfile.txt"
Set wshShell = Nothing
End Sub
</script>
</html>
[/code]

Regards
purcaholic
From: rf on
Swifty wrote:
> I know that JavaScript goes out of its way to make it impossible for
> local commands to be executed, but in a situation where I own
> everything; the server, the webpage, the local system, the browser
> (and anything else that you can think of), is there a way to execute a
> local command?

HTA?

Not the Hospital Training Association, HTML Applications. IE only.


From: Thomas 'PointedEars' Lahn on
purcaholic wrote:

> Swifty wrote:
>> To give you the specifics: The webpage is the source control for all
>> the HTML and CGI scripts on our department server (remote from me/my
>> PC). After I've checked out the file that I want to work on, it would
>> be nice if that file could be opened on my local system. To do this,
>> the JavaScript running on my local system would have to execute a
>> command such as:
>>
>> "C:\Program Fies\Editor\Edit.exe" "L:\path\to\file\filename"
>>
>> I realise that I'll probably have to make some adjustments to my
>> browser to accommodate this, but I prefer to keep these to a minimum,
>> as I use all sorts of different browsers, and I'd never be certain
>> which one I'd be using.
>> [...]
>
> [...]
> running a system process from a JavaScript within a webpage won't be
> possible due to security reasons.

A common misconception. It is a matter of available API and permissions,
not of the programming language.

> You can use a Java applet, or a Silverlight app to do this. There is
> also another way to do this with vbs/wsh if you are using a IE and if
> the security settings of your browser/system allow it.
>
> Following vbs example added to a webpage should work in ie:

In this case, the API is that of the Windows Scripting Host.

> [code]
> <input type="button" name="vbsExample" value="Run me" language="vbs"
> onclick="runEditor" />

OMG.

<input type="button" value="Run me" onclick="runEditor()">

<http://validator.w3.org/>

> <script language="vbs">

That is not going to work; needs to be "VBScript" instead:

<http://msdn.microsoft.com/en-us/library/3945y0f9%28VS.85%29.aspx>

> Sub runEditor
> Dim wshShell
> Set wshShell = CreateObject("WScript.Shell")
> wshShell.Run "notepad.exe C:\path\to\textfile.txt"
> Set wshShell = Nothing
> End Sub
> </script>

<script type="text/jscript" language="JScript">
function runEditor()
{
var wshShell = new ActiveXObject("WScript.Shell");
wshShell.Run("notepad.exe C:\\path\\to\\textfile.txt");
}
</script>

Please trim your quotes to the relevant minimum.


PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(a)news.demon.co.uk> (2004)
From: Sean Kinsey on
On Apr 7, 10:45 am, Swifty <steve.j.sw...(a)gmail.com> wrote:
> I know that JavaScript goes out of its way to make it impossible for
> local commands to be executed, but in a situation where I own
> everything; the server, the webpage, the local system, the browser
> (and anything else that you can think of), is there a way to execute a
> local command?
>
> To give you the specifics: The webpage is the source control for all
> the HTML and CGI scripts on our department server (remote from me/my
> PC). After I've checked out the file that I want to work on, it would
> be nice if that file could be opened on my local system. To do this,
> the JavaScript running on my local system would have to execute a
> command such as:
>
> "C:\Program Fies\Editor\Edit.exe" "L:\path\to\file\filename"
>
> I realise that I'll probably have to make some adjustments to my
> browser to accommodate this, but I prefer to keep these to a minimum,
> as I use all sorts of different browsers, and I'd never be certain
> which one I'd be using.
>
> If it helps, I could easily create a CGI script to run under apache on
> my local system, and that could be used as the mechanism that actually
> issues the host command. So the JavaScript running on my local PC
> could issue some sort of httprequest to my local apache to cause the
> editor to launch.
>
> --
> Steve Swifthttp://www.swiftys.org.uk/swifty.htmlhttp://www.ringers.org.uk

I guess you could register a custom protocol handler for this, e.g.
checkout:, and then you could just set the location to checkout://L:\path.....
 |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: detect exiting the website
Next: BESEN ES5 implementation