Solved

HTML Java script that executes network application

Posted on 2013-06-13
6
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

729 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