Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > JavaScript ActiveXObject error

Reply
Thread Tools

JavaScript ActiveXObject error

 
 
forum7
Guest
Posts: n/a
 
      10-26-2004
I need some immediate guidance with an error I am facing using an
ActiveXObject to instantiate a DLL and use the object to launch a
command on the local client. I use this great DLL called LaunchinIE
which works for the most part. But I am running into a hurdle in my
application, as described below...

I have set up an ASP page with the following code on the web server:

<html>
<head>
<title>Testing Application Launch In IE</title>
<script language="JavaScript">
function launchApp(strCmdLine)
{
var obj = new ActiveXObject("LaunchinIE.Launch");
obj.LaunchApplication(strCmdLine);
}
</script>
</head>
<body>
<script language="JavaScript">
var qt = '"';
var strCmdLine = 'C:\\ddc32\\ddc32.exe ';
strCmdLine += 'ddc(dsp(30, Application Login, Logging in to
Application..., 3) if w4w(2, Missing Client ID) else if w4i(40,GenQL,)
wait(6) skw(0,GenQL TSTUSER{enter}TSTPWD{enter}) endif endif dsp()) &&
';
strCmdLine += qt+'C:\\Program Files\\GenQL\\genql.exe'+qt + ' ';
strCmdLine += 'GenQL.App Name=Desktop70';
launchApp(strCmdLine);
</script>
</body>
</html>

On the client system, I registered the launchinIE.dll component that
suppresses the IE security prompt for opening or saving an executable.
Now, when I try to access this page from the client, the first part of
the command works, i.e. the ddc32 winbatch executable. But the second
part of the command is not recognized and a message box shows up
stating that the command is unknown.

Surprisingly, if I try the exact two commands from the DOS command
line, i.e.

C:\ddc32\ddc32.exe ddc(dsp(30, Application Login, Logging in to
Application..., 3) if w4w(2, Missing Client ID) else if w4i(40,GenQL,)
wait(6) skw(0,GenQL TSTUSER{enter}TSTPWD{enter}) endif endif dsp()) &&
"C:\Program Files\GenQL\genql.exe" GenQL.App Name=Desktop70

.... both commands are executed in sequence and work just fine. Since
the command is included in JavaScript, I had to escape the reverse
slash and alias the double quote character with a variable "qt". Also,
the && is more like Unix, where the result of the first command
decides whether or not to execute the second command. In other words,
if the first command returns TRUE, the second command is executed only
then. I know your DLL works just fine, because if I replace this long
command with something simpler like...

C:\ddc32\display1.bat ashwin && C:\ddc32\display2.bat raj

.... it works just fine. I feel this may be a JavaScript type of issue,
and it is somehow unable to parse the argument to the first command
ddc32, thereby failing the second command.

I greatly appreciate any help!
 
Reply With Quote
 
 
 
 
Michael Harris \(MVP\)
Guest
Posts: n/a
 
      10-26-2004
> ... I use this great DLL called LaunchinIE
> which works for the most part. But I am running into a hurdle in my
> application, as described below...


In that you are callng a method of a 3rd party component, your best bet is
to contact the author (email address from the site:
rockin_AT_whirlywiryweb.com).

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US

 
Reply With Quote
 
 
 
 
forum7
Guest
Posts: n/a
 
      10-27-2004
Mike,

I have done that too, and I think the author has been very forthcoming
in his support. Even then, this is an issue related to JavaScript,
because I can replace that long command string with something similar
like...

myObj.launchApplication("mdisplay1.bat ashwin && display2.bat raj");

....within LaunchinIE and it works just fine. But the similar syntax
and a different pair of commands (below) do not work. I think it may
have something to do with escaping the parentheses, ampersands or some
other character(s). The exact same pair of commands executed in a DOS
window works just fine, but not when invoked from the LaunchinIE
component the exact same way.

Thanks for your response.

--Ashwin

"Michael Harris \(MVP\)" <mikhar at mvps dot org> wrote in message news:<>...
> > ... I use this great DLL called LaunchinIE
> > which works for the most part. But I am running into a hurdle in my
> > application, as described below...

>
> In that you are callng a method of a 3rd party component, your best bet is
> to contact the author (email address from the site:
> rockin_AT_whirlywiryweb.com).

 
Reply With Quote
 
Michael Harris \(MVP\)
Guest
Posts: n/a
 
      10-27-2004
forum7 wrote:
> Mike,
>
> I have done that too, and I think the author has been very forthcoming
> in his support. Even then, this is an issue related to JavaScript,
> because I can replace that long command string with something similar
> like...
>
> myObj.launchApplication("mdisplay1.bat ashwin && display2.bat raj");
>


The rules for command lines executed via the component's LaunchApplication
method are probably the same as those for WshShell.Run since it is likely
just a wrapper around ShellExecuteEx.

Since the && only has meaning to the command shell (e.g. cmd.exe), you have
to be explicit and include the command processor in your command line

"%comspec% /c ...all that other stuff..."

A command line like

c:\foo.bat && c:\foo.bat

works because the command shell instance is started implicitly via the BAT
file association.

A command line like

notepad.exe && notepad.exe

would fail at the && since the command shell is not launched implicitly.

A command line like

%comspec% /c notepad.exe && notepad.exe

would work because the command shell is launched explicitly...


> ...within LaunchinIE and it works just fine. But the similar syntax
> and a different pair of commands (below) do not work. I think it may
> have something to do with escaping the parentheses, ampersands or some
> other character(s). The exact same pair of commands executed in a DOS
> window works just fine, but not when invoked from the LaunchinIE
> component the exact same way.
>
> Thanks for your response.
>
> --Ashwin
>
> "Michael Harris \(MVP\)" <mikhar at mvps dot org> wrote in message
> news:<>...
>>> ... I use this great DLL called LaunchinIE
>>> which works for the most part. But I am running into a hurdle in my
>>> application, as described below...

>>
>> In that you are callng a method of a 3rd party component, your best
>> bet is to contact the author (email address from the site:
>> rockin_AT_whirlywiryweb.com).


--
Michael Harris
Microsoft.MVP.Scripting

 
Reply With Quote
 
forum7
Guest
Posts: n/a
 
      10-29-2004
Mike,

Your suggestion did help! Now, I am able to get the two commands to
get executed via the component's LaunchApplication method. The
problem, however, is that the command shell window (blank) is open for
the duration of execution of the two commands. I tried looking up the
argument list for cmd.exe to see if there was some way to suppress
this window or auto-close in a given amount of time. I could not find
anything. This is not a show-stopper, but there may be risks
associated with having that window open for a long time. Do you have
any suggestions?

You have been extremely helpful -- thank you so much!

--Ashwin

"Michael Harris \(MVP\)" <> wrote in message news:<>...
>
> The rules for command lines executed via the component's LaunchApplication
> method are probably the same as those for WshShell.Run since it is likely
> just a wrapper around ShellExecuteEx.
>
> Since the && only has meaning to the command shell (e.g. cmd.exe), you have
> to be explicit and include the command processor in your command line
>
> "%comspec% /c ...all that other stuff..."
>
> A command line like
>
> c:\foo.bat && c:\foo.bat
>
> works because the command shell instance is started implicitly via the BAT
> file association.
>
> A command line like
>
> notepad.exe && notepad.exe
>
> would fail at the && since the command shell is not launched implicitly.
>
> A command line like
>
> %comspec% /c notepad.exe && notepad.exe
>
> would work because the command shell is launched explicitly...

 
Reply With Quote
 
Michael Harris \(MVP\)
Guest
Posts: n/a
 
      10-29-2004
> Your suggestion did help! Now, I am able to get the two commands to
> get executed via the component's LaunchApplication method. The
> problem, however, is that the command shell window (blank) is open for
> the duration of execution of the two commands. I tried looking up the
> argument list for cmd.exe to see if there was some way to suppress
> this window or auto-close in a given amount of time. I could not find
> anything. This is not a show-stopper, but there may be risks
> associated with having that window open for a long time. Do you have
> any suggestions?


Unless the author of the component included support in the LaunchApplication
method for a window style argument (such as WshShell.Run does) to run in a
hidden window, then I don't know of any way for cmd.exe to hide itself.

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add data validation Using javascript ActivexObject hukoh Javascript 0 06-15-2012 02:34 AM
javascript, new ActiveXObject() and events =?Utf-8?B?RXVnZW5l?= ASP .Net 3 08-15-2007 01:50 PM
ListBox, ActiveXObject =?Utf-8?B?T3Jlbg==?= ASP .Net 1 04-08-2004 09:45 AM
ActiveXObject Oren ASP .Net 1 11-24-2003 07:50 PM
ActiveXObject("MSXML2.DOMDocument.4.0") error K. Wilder ASP General 1 09-16-2003 05:11 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57