Link to home
Start Free TrialLog in
Avatar of aletheia1
aletheia1

asked on

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
Avatar of justinbillig
justinbillig

are you sure the path is correct. Are you running this function on the server or the client?
Avatar of aletheia1

ASKER

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...
then the path to that file has to be the path it is on the client currently running the EXE
But I want to open a file that is on the server.

This function doesn't accept this syntax?
"\\serverName\dirName\fileName.rep"
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
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?
I tried this:

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

But error is: "Authorization denied"...
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

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
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
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!
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial