I'm not sure which version of rev you are using but you may not need to use the shell() function.

I personally use vbscript to get WMI data from the PC such as HDD and USB Hardware serial numbers. I use the WMI Code Creator availible from microsoft's website to generate the vbs code.
http://www.microsoft.com/downloads/details.aspx?FamilyID=2cc30a64-ea15-4661-8da4-55bbc145c30e
This is a little long winded and perhaps a little more involved than you need but I want to be pretty clear on how I manage it.

so... I want to enumerate usb devices attached to the PC...I know this information (and lots more) is availible through WMI in windows.

Fire up WMI Code Creator (you may need dot.net crap installed)
Select "Query for data from a WMI Class"
Select "root/CIMV2" as a namespace
Select "Dependant" from the properties field

Pure vbs code will be generated for you in the "Generated Code" window:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
   "SELECT * FROM Win32_USBControllerDevice",,48)
For Each objItem in colItems
   Wscript.Echo "-----------------------------------"
   Wscript.Echo "Win32_USBControllerDevice instance"
   Wscript.Echo "-----------------------------------"
   Wscript.Echo "Dependent: " & objItem.Dependent
Next

From here you have 2 Options:

The 1st Option:

Save or write the generated code to a *.vbs file either staticly or dynamicly, and call it using
put shell("cscript c:\MyWMIQuery.vbs") --this will dump the result to stdout
put shell("cscript c:\MyWMIQuery.vbs") into tVariable -- this will dump the result into variable tVariable put shell("cscript c:\MyWMIQuery.vbs") into field "field" --this will dump the result into a field called "field"

The downside is your code will be "exposed" as plain text and you will have to set the hideConsoleWindows to true or your user will see the vbs script executing in the command line window.

The 2nd and my preferred option is to use the "do *SCRIPT* as vbscript" function in runrev.

The main thing you need to know is that when your vbs function is executed in THIS way, the result of the vbs function will have to be stored in a variable called "result" in your vbscript, thus it will be transferred to "the result" variable in runrev.

What I do is put my modified WMI vbscript into a field "fldScript" in runrev this makes it easier to read, however it does not have to be visible :)

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
   "SELECT * FROM Win32_USBControllerDevice",,48)
For Each objItem in colItems
    tTemp = tTemp & vbcrlf & objItem.Dependent
Next
result = tTemp

Note how my rev version of the vbs script makes no use of "Wscript.Echo" because it is no use for us here. So I have also removed the fancy formatting stuff:
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_USBControllerDevice instance"
They serve no purpose to us, we only want the raw information which is returned in vbs by the function "objItem.Dependant"

What I did was instead of echoing the values to stdout I concatenated them to the vbs "tTemp" Variable, Once I have all the information I need in the tTemp variable, finally assign it to a variable called "result" in vbscript.

To call it and get info back in rev you can then use:

do field "fldScript" as vbscript
put the result --this will dump the result of the vbscript to stout

do field "fldScript" as vbscript
put the result into field "fldOutput" --this will dump the result of the vbs function into a field called "fldOutput"
etc...

One last piece of advice I would issue is do only very minimum with vbs, the result of the above function contains all sorts of information but I would rather sift through it with revTalk than vbscript. The main lines I am interested in are the ones containing "USBSTOR"

Hope this helps.
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to