Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WScript from Internet Explorer Browser

793 views
Skip to first unread message

Frank Huddleston

unread,
Dec 10, 2001, 1:06:24 PM12/10/01
to
I'm trying to execute some WScript methods from within the browser.
I've seen some previous posts which address this, and suggest the
following:
var WshShell;
WshShell = new ActiveXObject("WScript.Shell");

I have this in my script, but get an error saying:
"Automation server can't create Object".

Does anyone know what I should do to make this work correctly? My
workstation is Win2K Professional, the IE browser says it's 6.0, and
my WSH version is 5.6.
Thanks.

Gurgen

unread,
Dec 10, 2001, 3:50:11 PM12/10/01
to
Try reinstalling WSH and reboot PC.

Gurgen.


"Frank Huddleston" <Frank.Hu...@brooks.af.mil> wrote in message
news:db089bff.0112...@posting.google.com...

Frank Huddleston

unread,
Dec 10, 2001, 4:18:43 PM12/10/01
to
OK, I tried that. No change.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Michael Harris (MVP)

unread,
Dec 10, 2001, 5:08:39 PM12/10/01
to
You can use any COM object inside IE hosted script provided you want to deal with the hassles of the IE enforced security model regarding "unsafe ActiveX...". Whether the user allows this is strictly up to them. There is no way to do this silently without some prior acknowledgement and permission from the end user...

Whether you use JScript's new ActiveXObject() or VBScript's CreateObject() or whether you get the prompt or the failure, the issues are still the same...

Q195826 - PRB: CreateObject Fails from Client-Side Scripts
http://support.microsoft.com/support/kb/articles/Q195/8/26.ASP

Or you can simply use HTAs instead - as simple as saving the file with .hta instead of .htm as the extension. .hta files are hosted by mshta.exe rather than iexplore.exe, and have a security model comparable to a conventional Windows desktop application. Of course accepting and executing an HTA is also up to the end user...


--
Michael Harris
Microsoft.MVP.Scripting
--

"Frank Huddleston" <Frank.Hu...@brooks.af.mil> wrote in message news:db089bff.0112...@posting.google.com...

Frank Huddleston

unread,
Dec 10, 2001, 5:46:40 PM12/10/01
to
Thanks that helps, but still not working:
In the Intranet zone, I set to prompt for unsafe ActiveX controls, etc. I get the prompt, but still get the error message. The info article to which you referred me says this can also result from the control being installed incorrectly. I have no idea how to correct for this, other than the original suggestion of reinstalling WSH. Any others?
As for HTA, I have no experience with it, but it appears that it uses a different DOM from HTML. I was using a frameset, getting a computer name from one frame, passing that to a JScript function which would establish a connection with the specified computer (this is where I receive the "cannot create object" error), and then be ready for other requests to be chosed as hyperlinks from the control or directory frame. The computer name is passed as "document.forms[0].computerName.value" to the JavaScript function - the HTML version recognizes this, but the HTA version doesn't. Where can I get some idea of the DOM used by HTA?
The application is intended to be a browser-based, JScript, selectable version of Micheal Harris' wmi_enumerate.vbs.
Thanks again.

Frank Huddleston

unread,
Dec 10, 2001, 5:54:39 PM12/10/01
to
An update: at this point, it's not the first of these three statements that is getting the error - it's the second; the "WbemLocator = " statement.

function connectComputer( computerName ) {

WshShell = new ActiveXObject("WScript.Shell");

WbemLocator = WshShell.CreateObject("WbemScripting.SWbemLocator");
WbemService = WbemLocator.ConnectServer(computerName);
}

The current error is:
Object doesn't support this property or method.

Gurgen

unread,
Dec 10, 2001, 6:03:36 PM12/10/01
to
To narrow down the problem, I would copy those 2 lines to test.js and try to
run it.

Gurgen.


"Gurgen" <gur...@bellatlantic.net> wrote in message
news:u0Au4xbgBHA.2496@tkmsftngp03...

Michael Harris (MVP)

unread,
Dec 10, 2001, 9:59:22 PM12/10/01
to
The WshShell object doesn't have a CreateObject method.

Just use new ActiveXObject...

WbemLocator = new ActiveXObject("WbemScripting.SWbemLocator");

--
Michael Harris
Microsoft.MVP.Scripting

"Frank Huddleston" <frank.hu...@brooks.af.mil> wrote in message news:#u4Dn2cgBHA.1884@tkmsftngp04...

Frank Huddleston

unread,
Dec 11, 2001, 1:36:34 PM12/11/01
to
That worked fine; thank you very much. I had that code in other WSH
scripts; strange that it seemed to work and didn't give me an error,
until now when I'm trying to run the code in the browser context.
Thanks again.

Frank Huddleston

0 new messages