WMI script

rantpe's picture

Hi
I trying to create WMI script (with VMI Code creator):
---------------------- BOF -----------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\DEFAULT")
' Obtain an instance of the the class
' using a key property value.
Set objShare = objWMIService.Get("VirtualSoftwarePackage")

' Obtain an InParameters object specific
' to the method.
Set objInParam = objShare.Methods_("Import"). _
    inParameters.SpawnInstance_()

' Add the input parameters.
objInParam.Properties_.Item("Filename") =  "C:\SWVAPPS\XnView2.vsa"
objInParam.Properties_.Item("Overwrite") =  True

' Execute the method and obtain the return status.
' The OutParameters object in objOutParams
' is created by the provider.
Set objOutParams = objWMIService.ExecMethod("VirtualSoftwarePackage", "Import", objInParam)

' List OutParams
Wscript.Echo "Out Parameters: "
Wscript.echo "PackageId: " & objOutParams.PackageId
Wscript.echo "ReturnValue: " & objOutParams.ReturnValue
------------------------ EOF ----------------------

Result
Out Paramets : " " (none)
PackageId:
ReturnValue: 1040

What i am doing wrong here (i newbie with WMIscript)

-Petri

EdT's picture

What are you seeing?

First of all, standard WMI does not know about Virtual Packages, so do you have whatever is necessary to be installed to provide this add-on functionality?
Secondly, what are you trying to do? We need to know this rather than try and guess from your code - if the code is wrong we can end up chasing the wrong tail.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

AngelD's picture

Have a look

Have a look at http://www.symantec.com/connect/articles/svs-and-wmi-windows-management-instrumentation
see the Sample Functions - Import "section"

rantpe's picture

What i try to do

I am not very good at writing vbs scripts.
But now i have to vbs script for SCCM/SMS to import and activate (auto) apps.
I was trying to use WMI code creator to create base script to import application.

-Petri