Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2003
    Posts
    591
    Rep Power
    24

    JavaScript "WScript.Shell"!


    Hi, everyone

    I created this JavaScript function in my ASP page:

    function runReport(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
  2. #2
  3. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    if it works for you without any confirm dialog box, it's really really bad: any website can have full control over your computer!
    anyways, that error message means you gave invalid path, for example "C:\kgjkdgg.fjd" where file named "kgjkdgg.fjd' does not exist in drive C. note that you must give it full path to the file.
  4. #3
  5. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2003
    Posts
    591
    Rep Power
    24
    Hi, Shadow Wizard :-)

    Originally Posted by Shadow Wizard
    if it works for you without any confirm dialog box, it's really really bad: any website can have full control over your computer!
    Don't worry, there is confirm dialog box.
    I just didn't mention it.

    Originally Posted by Shadow Wizard
    anyways, that error message means you gave invalid path, for example "C:\kgjkdgg.fjd" where file named "kgjkdgg.fjd' does not exist in drive C. note that you must give it full path to the file.
    I also tried to give full path (correct of course), but the message error is the same. It's strange. ALL the other programs don't give me any error...
  6. #4
  7. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    what path did you give?
  8. #5
  9. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2003
    Posts
    591
    Rep Power
    24
    I have to open a report that is on the server.

    1) "\\serverName\dirName\reportName.rep"

    it doesn't work, so I thought that this function doesn't accept this kind of path.

    Just for curious, I tried to open directly the program:

    2) "C:\Program Files\Business Objects\BusinessObjects 5.0\BUSOBJ.EXE"

    but it doesn't work either. The message error is always the same ("can't find the specified file")
  10. #6
  11. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    if the file is on the server, why not simply put link to that file?? then program will automatically open the file when user click Open...
  12. #7
  13. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2003
    Posts
    591
    Rep Power
    24
    It's a long story... :-(

    By the way, this function accepts only physical path? Or the syntax "\\serverName\..." should work anyway?
  14. #8
  15. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    it should work, but it may be permissions problem. I'm not sure though... sorry.
  16. #9
  17. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2003
    Posts
    591
    Rep Power
    24
    I also tried this:

    var rep = new ActiveXObject("Shell.Application");
    rep.shellExecute("C:\Program Files\Business Objects\BusinessObjects 5.0\BUSOBJ.EXE",repPath,"open","1");

    But error is: "Authorization denied"...
  18. #10
  19. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    sorry, I'm out of ideas. try to ask someone who is expert in the network and permissions stuff if this can be permissions problem and if so grant proper permissions to the program or proper user account.
  20. #11
  21. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Oct 2003
    Posts
    591
    Rep Power
    24
    Hi Shadow Wizard,
    I solved the problem and I wanted to let you know:

    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!

    Thanks anyway for your support and interest, I appreciate very much :-)
  22. #12
  23. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    hmm... so that error was from the business program itself. I thought it was about BUSOBJ.EXE file which can't be found.
  24. #13
  25. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2005
    Posts
    2
    Rep Power
    0
    hey aletheia2!

    You mentionned that with this code you can open exe.

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

    But it dosent work for me!

    i get "Automation Server can"t create object"

    Do you know why i get this error?

    I use ASP.NET and VB.NEt.

    Thanks a lot!
  26. #14
  27. Web-Standards Evangelist
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Nov 2003
    Posts
    1,522
    Rep Power
    14
    ...Because:

    a) those languages are server-side
    b) by default the ASP parser only uses the VBS scripting engine
    c) ...and you cannot invoke any of the normally intrinstic WScript objects from ASP
    d) ...and because the syntax for ASP is "Server.CreateObject(clsid | ProgID)" compared to "CreateObject(clisd | ProgID)" for client-side
  28. #15
  29. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    this is client-side only code. only IE browser allow such code to run, and only after you allow it via the settings:
    Tools --> Internet Options --> Security --> Custom --> unsigned activeX controls --> Prompt.
    never have "allow" in there, or you'll get millions of worms and viruses.
Page 1 of 2 12 Last
  • Jump to page:

Similar Threads

  1. how to prevent javascript menu from being hidden back by <iframe>
    By arif_1947 in forum HTML, JavaScript And CSS Help
    Replies: 6
    Last Post: March 31st, 2005, 04:06 PM
  2. Replies: 2
    Last Post: November 3rd, 2004, 01:42 AM
  3. Getting VB variable from Server-Side Javascript
    By asmoran in forum ASP Development
    Replies: 7
    Last Post: August 27th, 2004, 01:29 PM
  4. accessing controls embedded in a user control via javascript
    By dwicker in forum HTML, JavaScript And CSS Help
    Replies: 2
    Last Post: May 27th, 2004, 02:28 AM
  5. javascript commands not doing anything
    By cal_gecko in forum HTML, JavaScript And CSS Help
    Replies: 1
    Last Post: April 11th, 2004, 03:39 PM

IMN logo majestic logo threadwatch logo seochat tools logo