• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5882
  • Last Modified:

WScript.Shell doesn't open a program!

Hi, everyone

I created this JavaScript function in my ASP page:

function runReport(repPath)
{
      alert(repPath);
      var rep = new ActiveXObject("WScript.Shell");
      rep.Run(repPath, 1, true);
}

it seems to work fine: for example, notepad.exe, winword.exe... every program is opened correctly.
But I have one program, that I need to open my reports, that doesn't work. The error message is "Impossible to find the specified file".
I even added in the local system variable "PATH" the .exe file of this program, but anyway it doesn't work.

What's the matter?

Every help is appreciated.
Thanks in advance
0
aletheia1
Asked:
aletheia1
  • 5
  • 4
  • 2
  • +1
1 Solution
 
justinbilligCommented:
are you sure the path is correct. Are you running this function on the server or the client?
0
 
aletheia1Author Commented:
Hi

Yes, I'm sure that the path is correct... (it's the only one that doesn't work!)

I'm running this function from the client, it's a javascript function...
0
 
justinbilligCommented:
then the path to that file has to be the path it is on the client currently running the EXE
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
aletheia1Author Commented:
But I want to open a file that is on the server.

This function doesn't accept this syntax?
"\\serverName\dirName\fileName.rep"
0
 
justinbilligCommented:
Hrm, are theres computers on the same network, cause if they arent then you can't do that.

Also wscript can only run .exe, .com, .bat files
0
 
aletheia1Author Commented:
Yes, they are on the same network.

>>Also wscript can only run .exe, .com, .bat files
But, even calling the .exe, it gives me the same error message.

Is there other objects instead of WScript.Shell?
0
 
aletheia1Author Commented:
I tried this:

var rep = new ActiveXObject("Shell.Application");
rep.shellExecute("C:\dirName\fileName.exe",repPath,"open","1");

But error is: "Authorization denied"...
0
 
VincentPugliaCommented:
Hi,

1) How do you expect to 'run' a file with ext 'rep'????  In other words, what type of a file is that?

2) AFAIK, Wscript only runs on the client

3) "Authorization denied" implies you don't have permissions -- security levels

4) c:\\dirName\\fileName.exe -- if it is not a Windows installed program, you need (at least) double "\\"

5) if you are trying to access a file from an intranet -- assign a drive letter to the server directory; see DOS' SUBST command -- then use that drive letter:  N:\\filename.exe

Vinny

0
 
justinbilligCommented:
the only thing vinny is if this is going to run on multiple machines, my N drive might not be the server you mapped for the n drive
0
 
VincentPugliaCommented:
If it's an intranet, the N drive should be the same drive for all the clients -- that's what the network supervisor is for -- to make sure mappings are consistent and appropriate
0
 
aletheia1Author Commented:
I solved the problem with this syntax:

var rep = new ActiveXObject("WScript.Shell");
var str = new String;
str = "BUSOBJ.EXE \"" + repPath + "\"";
rep.Run(str, 1, true);

I had to call the .exe with the file path and name as parameter.
Now it works perfectly!
0
 
moduloCommented:
Closed, 100 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now