PDA

View Full Version : Help! I failed to run the javascript



Smart_boy
06-20-2008, 02:09 AM
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:



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!

josephhamilton1
06-20-2008, 02:46 AM
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...

Smart_boy
06-20-2008, 03:43 AM
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!

josephhamilton1
06-20-2008, 03:27 PM
Which line is line 88?

Smart_boy
06-22-2008, 04:15 PM
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:



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!