SWbemObject.SpawnInstance_ method
Use the SpawnInstance_ method of the SWbemObject object to create a new instance of a class. The current object must be a class definition obtained from WMI via a method such as SWbemServices.Get or SWbemServices.ExecQuery. Then, use this class definition to create new instances. Create each new instance locally within the process, and then call SWbemObject.Put_ to actually create the instance within WMI.
Note Spawning an instance from an instance is supported, but the returned instance is empty.
For an explanation of this syntax, see Document Conventions for the Scripting API.
Syntax
objNewInstance = .SpawnInstance_( _
[ ByVal iFlags ] _
)
Parameters
- iFlags [in, optional]
-
Reserved and must be zero if specified.
Return value
If successful, this call returns an SWbemObject object that contains a new instance of the class.
Error codes
After the completion of the SpawnInstance_ method, the Err object may contain one of the error codes in the following table.
| Error (Name/Dec/Hex) | Meaning |
|---|---|
|
Current object is not a valid class definition, and it cannot spawn new instances. Either it is incomplete, or it has not been registered with WMI using SWbemObject.Put_. |
|
Returned if this method is used on an instance instead of a class. |
|
Invalid parameter was specified. |
|
Not enough memory to complete the operation. |
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
Requirements
|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Type library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/19/2012