Page 1 of 1 1
Topic Options
#93083 - 2003-10-08 11:52 PM Problem updating the properties of a new SWbemLocator object.
Anonymous
Unregistered


I'm trying to convert the following VB code to KIX. It's actually to automate the creation of a SMS package within SMS 2.0 but I'm guessing it would apply anywhere:

code:
Set objWbemLocator 	= CreateObject("WbemScripting.SWbemLocator")
Set SMSConnection = objWbemLocator.ConnectServer("SERVERNAME","Root\sms\site_XXX")

Set instPackage = SMSConnection.Get("SMS_Package").SpawnInstance_

instPackage.Description = "Office 2000 installation"
instPackage.Manufacturer = "Microsoft"
instPackage.Name = "Office 2000"

instPackage.Put_ 0, SMSContext

I've got this far, but I can't work out what I'm doing wrong with the PUT_

code:
$oWBEMLoc=CreateObject("WbemScripting.SWbemLocator")
$oWBEMSrv=$oWBEMLoc.ConnectServer("SERVERNAME", "root\SMS\site_XXX")
$oNewPackage=$oWBEMSrv.Get("SMS_Package").SpawnInstance_

$oNewPackage.Description = "Office 2000 installation"
$oNewPackage.Manufacturer = "Microsoft"
$oNewPackage.Name = "Office 2000"

$=$oNewPackage.Put_(0, "SMSContext")

Can anyone point out where I'm going wrong - it's stumped me ;-(

Top
#93084 - 2003-10-09 02:08 AM Re: Problem updating the properties of a new SWbemLocator object.
SpongeBobSquarePants Offline
Lurker

Registered: 2002-03-24
Posts: 3
Loc: UnderSea
Hope this isn't a dumb question, but did you post the entire script, is there a

Set SMSContext = ...

kicking around in there somewhere ?

-Bob

[ 09. October 2003, 02:12: Message edited by: SpongeBobSquarePants ]

Top
#93085 - 2003-10-09 04:11 AM Re: Problem updating the properties of a new SWbemLocator object.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
$oNewPackage.Put_(0, $SMSContext) with $SMSContext being NULL ?
_________________________
There are two types of vessels, submarines and targets.

Top
#93086 - 2003-10-09 03:35 PM Re: Problem updating the properties of a new SWbemLocator object.
Anonymous
Unregistered


No, I couldn't work out from where that came. The original script is actually full VB - see the following link from MSDN:
Creating a Package and Programs Using SMS Classes

I looked a little closer at PUT_ SWbemObject.Put_ and it talks about this either being blank, or being a value name from a provider that is servicing this request.

It *seems* to work without the rest of the PUT_

code:
$=$oNewPackage.Put_

but I wonder if it's not actually really doing what I ask it to...

Top
#93087 - 2003-10-09 04:31 PM Re: Problem updating the properties of a new SWbemLocator object.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Check the error code afterwards. What's the indication that it actually is not doing the correct thing?
_________________________
There are two types of vessels, submarines and targets.

Top
#93088 - 2003-11-04 01:52 AM Re: Problem updating the properties of a new SWbemLocator object.
Anonymous
Unregistered


OK so you were right, the constant was missing.

This is the line of code I missed off:

code:
 
Dim SMSContext As New SWbemNamedValueSet
SMSContext.Add "LocaleID", "MS\1033"
SMSContext.Add "MachineName", "MyMachine"
SMSContext.Add "ApplicationName", "MyApp"

How would I create an array as SWbemNamedValueSet and add my own values?

Thanks in advance

Top
#93089 - 2003-11-04 02:10 AM Re: Problem updating the properties of a new SWbemLocator object.
SpongeBobSquarePants Offline
Lurker

Registered: 2002-03-24
Posts: 3
Loc: UnderSea
To create your contexts, how about:

$SMSContext = CreateObject("WbemScripting.SWbemNamedValueSet")

$SMSContext.Add("LocaleID", "MS\1033")
$SMSContext.Add("MachineName", "MyMachine")
$SMSContext.Add("ApplicationName", "MyApp")

Just a wild quess from the spongster.

Top
#93090 - 2003-11-04 02:52 PM Re: Problem updating the properties of a new SWbemLocator object.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
good one oh square panties! [Razz]
_________________________
!

download KiXnet

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.061 seconds in which 0.034 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