Page 1 of 1 1
Topic Options
#121594 - 2004-06-21 06:57 PM Loading enumerated constants into KiXtart via WSH?
New Mexico Mark Offline
Hey THIS is FUN
****

Registered: 2002-01-03
Posts: 223
Loc: Columbia, SC
I'm testing some code to check / manage VMWare virtual machines using their scripting API. The first script I've written works except for evaluating enumerated constants. After a little research (i.e. RTFM some more), I'm seeing that VMWare runs the following code fragment (with the appropriate src file) with cscript.exe to run each script.

<job id="Sample2">
<reference object="VmCOM.VmCtl" />
<script language="VBScript" src="sample2.vbs" />
</job>

Apparently doing it this way allows enumerated constants to be set up automatically prior to script execution.

Is there any way of getting this to work with KiXtart? I'm not finding KiXtart in the VBS documentation I downloaded, but I figured one of you COM gurus out there has run into something similar at some point.

Thanks,

NMM


Edited by New Mexico Mark (2004-06-21 08:01 PM)

Top
#121595 - 2004-06-21 09:00 PM Re: Loading enumerated constants into KiXtart via WSH?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Ran into it only from the view-point that I wished this worked with Kixtart. To the best of my knowledge, Kixtart does not support enumerated constants. Wish it did and it has been asked for in the past.
Top
#121596 - 2004-06-21 10:09 PM Re: Loading enumerated constants into KiXtart via WSH?
New Mexico Mark Offline
Hey THIS is FUN
****

Registered: 2002-01-03
Posts: 223
Loc: Columbia, SC
Actually, I'm not sure if the scripting language itself has to support enumerated constants. Here is the comment in one of the sample VB Scripts.

' - there should be an accompanying file named 'sample2.wsf'
' It is placed in the same directory as this file during
' product installation. This file is responsible for setting
' up the Windows Script Host environment and loading the
' VmCOM type library, thereby enabling this script to
' reference symbolic constants such as vmExecutionState_On
'
' - in a command line window, type:
' cscript //nologo sample2.wsf


Apparently, by running this script first (code included in my first message), all the symbolic constants are available with the called scripting environment.

I'm not sure whether there is a way to call KiXtart in this way from WSH so these constants are available there. It might just be easier to stick with VBScript?

NMM

Top
#121597 - 2004-06-21 10:13 PM Re: Loading enumerated constants into KiXtart via WSH?
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
well, take a look at this wsf file, and see what value these constants are being set to then just set your own kix variables if you want.
Top
#121598 - 2004-06-21 10:17 PM Re: Loading enumerated constants into KiXtart via WSH?
New Mexico Mark Offline
Hey THIS is FUN
****

Registered: 2002-01-03
Posts: 223
Loc: Columbia, SC
FWIW, here is the error I get when changing the WSF code as follows:

<job id="List_VMs">
<reference object="VmCOM.VmCtl" />
<script language="KiXtart" src="List_VMs.kix" />
</job>

Windows Script Host: The value for the attribute is not valid : language

Top
#121599 - 2004-06-21 10:21 PM Re: Loading enumerated constants into KiXtart via WSH?
New Mexico Mark Offline
Hey THIS is FUN
****

Registered: 2002-01-03
Posts: 223
Loc: Columbia, SC
I wish it were so easy.

Apparently, this is a scripting trick that makes all the constants in the VMCom.VMCtl object available to the scripting environment. I have no idea how to pull those constants out of that object manually. (And the ability to do so would probably depend upon enumerated constants, which KiXstart doesn't support!)

Top
#121600 - 2004-06-22 01:13 AM Re: Loading enumerated constants into KiXtart via WSH?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I think you just beautifully answered your own question but - why are you so hot on loading these enums ? You can just load the "VMCom.VMCtl" namespace in a typelib viewer, or vb/vba object viewer, and just pull out the constants you need and make $vars from them. Or do what some other folks do, make an include .kix/.udf file that has all these enums defined as $vars - just hand-job the whole kit-and-kaboodle.

Top
#121601 - 2004-06-23 11:34 PM Re: Loading enumerated constants into KiXtart via WSH?
New Mexico Mark Offline
Hey THIS is FUN
****

Registered: 2002-01-03
Posts: 223
Loc: Columbia, SC
I had forgotten I could use the vba object viewer -- told you I wasn't a major com coder. Got the constants extracted. Will work on this some more tomorrow.

Thanks!

NMM

Top
#121602 - 2004-06-24 10:20 AM Re: Loading enumerated constants into KiXtart via WSH?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Still, it would be nice to pull them out automatically. It would make (auto) conversion of VB far simpler.

If there is no way enumerate the enumerations in KiXtart, perhaps there is a command line utility which can pull the details out?

I haven't found anything so far, and coding anything in 'C' for accessing automation objects is a bit of a nightmare.

Update:
It can be done with a PERL module: http://www.xav.com/perl/site/lib/Win32/OLE/Const.html

And PHP: http://uk.php.net/manual/en/function.com-load-typelib.php


Edited by Richard H. (2004-06-24 11:49 AM)

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 476 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.061 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org