Results 1 to 5 of 5

Thread: Help! I failed to run the javascript

  1. #1
    Join Date
    May 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help! I failed to run the javascript

    Hi all,

    I use the .hta to run my javascript code. But there shown an error to the script. I don't know what happen to my script. Please help to check.
    I'm newbie for the javascript. Hope can get a help from you all. Thanks!

    My error part of the javascript is show as below:

    Code:
    var WScript = new Object();
    var WScript.Arguments = new ActiveXObject("WScript.Shell");
    
    if (WScript.Arguments.Length >= 1) {
    
        Application = WScript.Arguments(0);
        Arguments = "";
    
        for (Index = 1; Index < WScript.Arguments.Length; Index += 1) {
    
            if (Index > 1) {
                Arguments += " ";
            }
    
            Arguments += WScript.Arguments(Index);
        }
    
        new ActiveXObject("Shell.Application").ShellExecute(Application, Arguments, "", "runas");
    }
    
    else {
    
        WScript.Echo("Usage:");
        WScript.Echo("elevate Application Arguments");
    }
    }
    The error message is shown as below:

    An error has occurred in the script of this page

    Line: 70
    Char: 1
    Error: 'Argument.Length' is not null or an object
    Code: 0
    URL: file:C:/Users/Install/autorun/setup.hta

    Thank you!

  2. #2
    Join Date
    Jun 2008
    Location
    Denham Springs, LA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    var WScript = new Object();
    var WScript.Arguments = new ActiveXObject("WScript.Shell");

    remove the 2nd var, you only need to var it once like this:

    var WScript = new Object();
    WScript.Arguments = new ActiveXObject("WScript.Shell");

    and this will not work:

    new ActiveXObject("Shell.Application").ShellExecute(Application, Arguments, "", "runas");

    you have to set this equal to something like:

    var myVariable = new ActiveXObject...

  3. #3
    Join Date
    May 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi josephhamilton1,

    Thanks for your reply. i edit the coding already, but the error still occur and show that

    An error has occurred in the script of this page

    Line: 88
    Char: 5
    Error: Object doesn't support this property or method
    Code: 0
    URL: file:C:/Users/Install/autorun/setup.hta

    Thanks for help!

  4. #4
    Join Date
    Jun 2008
    Location
    Denham Springs, LA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Which line is line 88?

  5. #5
    Join Date
    May 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi josephhamilton1,

    Thanks for you help. i get a new problem again with the javascript. Hope can get a help from u and every one member of here.

    I run the script successfully in Windows XP, but failed in Windows Vista.

    When i run in Windows Vista, there shown an error

    ERROR:
    A problem occurs while trying to perform your request.
    Please contact the distributor by referring to the following message if any:

    CMD : ./../setup/install.exe
    ERR : The requested operation requires elevation

    The code are show as below:

    Code:
    function exeList( Seq)
    {
        var sh = new ActiveXObject("WScript.Shell");
        var tmp = ls[ Seq];
        if (tmp)
        {       
            if ((('run' == tmp['type']) && gR) || (('dev' == tmp['type']) && gD)) {
                try
                {
                    if (1 == tmp['func']) {
                        eval( tmp['cmd']);
                    }
                   
                    else {
                        oX = sh.Exec( tmp['cmd']); // error in vista
                    }
                    chkStts( Seq);
                }
                catch(e) {
                    alert("ERROR:\n\n"
                      + "A problem occurs while trying to perform your request.\n"
                      + "Please contact the distributor by referring to the following             message if any:\n"
                      + "\n"
                      + "CMD : " + tmp['cmd'] + "\n"
                      + "ERR : " + e.description + "\n"
                    );
                }
            }
            else {
                exeList( ++Seq);
            }
        }
        else
        {
            finish();
        }
    }
    Anyone know what happen to this. Anyone know how to solve this problem?
    I really needs a help from you all.

    Thank you very much!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •