Solved

HTML Java script that executes network application

Posted on 2013-06-13
6
327 Views
Last Modified: 2013-06-14
We created an intranet page for my company.  One of the links needs to launch an in-house application.  I have a java link script (below) which works for a local file, but what about over the network?  What is the syntax for that?  

example:
</form>
<script> 
     function go()
    {
          w = new ActiveXObject("WScript.Shell");
          w.run('\\server\share\application.bat');
          return true;
    } 
</script>

Open in new window


I do not wish to install any 3rd party utilities on the clients launching the intranet page because there are like 400 machines.  My goal is to make this all server-side.  

Thanks in advance!
0
Comment
Question by:icecom4
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:BAKADY
ID: 39246334
this works under vbs:

<script type="text/vbscript">
     Public Function go
          Dim oShell
          Set oShell = CreateObject("WScript.Shell")
          oShell.run """\\server\shared path\program.exe"""
          go = true
    End Function
</script>

Open in new window

0
 

Author Comment

by:icecom4
ID: 39246353
I added your script to my html source but it does not show any forms or links.
0
 
LVL 4

Accepted Solution

by:
BAKADY earned 500 total points
ID: 39246708
then add just the quotes in javascript, like this :

w.run('"\\server\share\application.bat"');

Open in new window

if this doesn't work again, i don't have any idea....
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:icecom4
ID: 39246727
I was able to get this to launch a .exe over the network, but for some reason it wont start a working batch script.  Any ideas?
<script>
function LaunchApp() {
	if (!document.all) {
 
  		alert ("This ActiveXObject is only available for Internet Explorer");
		return; 
	}
	var ws = new ActiveXObject("WScript.Shell");
    ws.Exec("\\\\server\\share\\test.exe");
}
</script>

Open in new window

0
 

Author Comment

by:icecom4
ID: 39246761
ok, tried adding the quotes to first script I posted and it worked, thanks!

I was able to blend the two different scripts I posted above, below is the final product
Makes a form, with button, and has that IE alert which is useful.  

<script type = "text/Javascript">

function go() {
if (!document.all) {
 
  		alert ("This ActiveXObject is only available for Internet Explorer");
		return; 
	}
w = new ActiveXObject("WScript.Shell");
w.run("\\\\server\\share\\file.bat");
return true;
}

</script>
 
<form>
Run Batch
<input type="button" value="Go" onClick="return go()">
</form>

Open in new window

0
 
LVL 4

Expert Comment

by:BAKADY
ID: 39246915
rename the file from *.bat to *.cmd
try it and send a feedback... should work...
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question