Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - How do you call a method?

Reply
 
Old 05-05-2009   #1 (permalink)
OldDog


 
 

How do you call a method?

I am trying this another way;

I am writting ascrit that uses the following;

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array(".")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\CIMV2\Security\MicrosoftVolumeEncryption")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_EncryptableVolume", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)

So far, so good.

Win32_EncryptableVolume has a method called GetEncryptionMethod().

How do I call this method and get its properties?

OldDog - Please don't make me write this in PowerShell!

My System SpecsSystem Spec
Old 05-06-2009   #2 (permalink)
Alex K. Angelopoulos


 
 

Re: How do you call a method?

I would first get the instances, instead of doing a query; use the following
line in place of the ExecQuery statement:

Set volumes = objWMIService.InstancesOf("Win32_EncryptableVolume")

Then do this:
dim retval, em

for each volume in volumes
retval = volume.GetEncryptionMethod(em)
WScript.Echo em
next

The big issue here is that by reference parameter being passed into and back
out of GetEncryptionMethod.



"OldDog" <mikef2691@xxxxxx> wrote in message
news:6d1f2793-ac87-48bf-af78-803d0986e0b8@xxxxxx
Quote:

> I am trying this another way;
>
> I am writting ascrit that uses the following;
>
> Const wbemFlagReturnImmediately = &h10
> Const wbemFlagForwardOnly = &h20
>
> arrComputers = Array(".")
> For Each strComputer In arrComputers
> WScript.Echo
> WScript.Echo "=========================================="
> WScript.Echo "Computer: " & strComputer
> WScript.Echo "=========================================="
>
> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
> \CIMV2\Security\MicrosoftVolumeEncryption")
> Set colItems = objWMIService.ExecQuery("SELECT * FROM
> Win32_EncryptableVolume", "WQL", _
> wbemFlagReturnImmediately +
> wbemFlagForwardOnly)
>
> So far, so good.
>
> Win32_EncryptableVolume has a method called GetEncryptionMethod().
>
> How do I call this method and get its properties?
>
> OldDog - Please don't make me write this in PowerShell!
My System SpecsSystem Spec
Old 05-06-2009   #3 (permalink)
OldDog


 
 

Re: How do you call a method?

On May 6, 8:45*am, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
Quote:

> I would first get the instances, instead of doing a query; use the following
> line in place of the ExecQuery statement:
>
> Set volumes = objWMIService.InstancesOf("Win32_EncryptableVolume")
>
> Then do this:
> dim retval, em
>
> for each volume in volumes
> * * retval = volume.GetEncryptionMethod(em)
> * * WScript.Echo em
> next
>
> The big issue here is that by reference parameter being passed into and back
> out of GetEncryptionMethod.
>
> "OldDog" <mikef2...@xxxxxx> wrote in message
>
> news:6d1f2793-ac87-48bf-af78-803d0986e0b8@xxxxxx
>
>
>
Quote:

> > I am trying this another way;
>
Quote:

> > I am writting ascrit that uses the following;
>
Quote:

> > Const wbemFlagReturnImmediately = &h10
> > Const wbemFlagForwardOnly = &h20
>
Quote:

> > arrComputers = Array(".")
> > For Each strComputer In arrComputers
> > * WScript.Echo
> > * WScript.Echo "=========================================="
> > * WScript.Echo "Computer: " & strComputer
> > * WScript.Echo "=========================================="
>
Quote:

> > * Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
> > \CIMV2\Security\MicrosoftVolumeEncryption")
> > * Set colItems = objWMIService.ExecQuery("SELECT * FROM
> > Win32_EncryptableVolume", "WQL", _
> > * * * * * * * * * * * * * * * * * ** * *wbemFlagReturnImmediately +
> > wbemFlagForwardOnly)
>
Quote:

> > So far, so good.
>
Quote:

> > Win32_EncryptableVolume has a method called GetEncryptionMethod().
>
Quote:

> > How do I call this method and get its properties?
>
Quote:

> > OldDog - Please don't make me write this in PowerShell!- Hide quoted text -
>
> - Show quoted text -
Thank you Alex. That works like a charm.
My System SpecsSystem Spec
Old 05-06-2009   #4 (permalink)
OldDog


 
 

Re: How do you call a method?

On May 6, 8:45*am, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
Quote:

> I would first get the instances, instead of doing a query; use the following
> line in place of the ExecQuery statement:
>
> Set volumes = objWMIService.InstancesOf("Win32_EncryptableVolume")
>
> Then do this:
> dim retval, em
>
> for each volume in volumes
> * * retval = volume.GetEncryptionMethod(em)
> * * WScript.Echo em
> next
>
> The big issue here is that by reference parameter being passed into and back
> out of GetEncryptionMethod.
>
> "OldDog" <mikef2...@xxxxxx> wrote in message
>
> news:6d1f2793-ac87-48bf-af78-803d0986e0b8@xxxxxx
>
>
>
Quote:

> > I am trying this another way;
>
Quote:

> > I am writting ascrit that uses the following;
>
Quote:

> > Const wbemFlagReturnImmediately = &h10
> > Const wbemFlagForwardOnly = &h20
>
Quote:

> > arrComputers = Array(".")
> > For Each strComputer In arrComputers
> > * WScript.Echo
> > * WScript.Echo "=========================================="
> > * WScript.Echo "Computer: " & strComputer
> > * WScript.Echo "=========================================="
>
Quote:

> > * Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
> > \CIMV2\Security\MicrosoftVolumeEncryption")
> > * Set colItems = objWMIService.ExecQuery("SELECT * FROM
> > Win32_EncryptableVolume", "WQL", _
> > * * * * * * * * * * * * * * * * * ** * *wbemFlagReturnImmediately +
> > wbemFlagForwardOnly)
>
Quote:

> > So far, so good.
>
Quote:

> > Win32_EncryptableVolume has a method called GetEncryptionMethod().
>
Quote:

> > How do I call this method and get its properties?
>
Quote:

> > OldDog - Please don't make me write this in PowerShell!- Hide quoted text -
>
> - Show quoted text -
Thanks, Alex. That works like a charm. Here is my script;

dim retval, em
arrComputers = Array(".")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\\" & strComputer _
& "\root\CIMV2\Security\MicrosoftVolumeEncryption")
Set volumes = objWMIService.InstancesOf("Win32_EncryptableVolume")

for each volume in volumes
If volume.DriveLetter = "C:" then
retval = volume.GetEncryptionMethod(em)
WScript.Echo em
End If
Next
Next

<---------- End Script -------------------->

Note that I was only interested in the C: drive, hence the "If
volume.DriveLetter "

OldDog
My System SpecsSystem Spec
Old 05-06-2009   #5 (permalink)
Alex K. Angelopoulos


 
 

Re: How do you call a method?

"OldDog" <mikef2691@xxxxxx> wrote in message
news:5bc08f69-11c0-4639-a57e-c281757f3b84@xxxxxx
Quote:

> On May 6, 8:45 am, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
Quote:

> Thanks, Alex. That works like a charm. Here is my script;
>
> dim retval, em
> arrComputers = Array(".")
> For Each strComputer In arrComputers
> WScript.Echo
> WScript.Echo "=========================================="
> WScript.Echo "Computer: " & strComputer
> WScript.Echo "=========================================="
>
> Set objWMIService = GetObject("winmgmts:\\" & strComputer _
> & "\root\CIMV2\Security\MicrosoftVolumeEncryption")
> Set volumes = objWMIService.InstancesOf("Win32_EncryptableVolume")
>
> for each volume in volumes
> If volume.DriveLetter = "C:" then
> retval = volume.GetEncryptionMethod(em)
> WScript.Echo em
> End If
> Next
> Next
>
> <---------- End Script -------------------->
>
> Note that I was only interested in the C: drive, hence the "If
> volume.DriveLetter "
>
> OldDog

Finally, a real, working demo of Win32_EncryptableVolume. : )

Do GetProtectionStatus and GetConversionStatus work correctly with this as
well now? I wasn't sure if the problem was using ExecQuery to get the
instance references.

My System SpecsSystem Spec
Old 05-06-2009   #6 (permalink)
OldDog


 
 

Re: How do you call a method?

On May 6, 11:50*am, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
Quote:

> "OldDog" <mikef2...@xxxxxx> wrote in message
>
> news:5bc08f69-11c0-4639-a57e-c281757f3b84@xxxxxx
>
>
>
>
>
Quote:

> > On May 6, 8:45 am, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
> > Thanks, Alex. That works like a charm. Here is my script;
>
Quote:

> > dim retval, em
> > arrComputers = Array(".")
> > For Each strComputer In arrComputers
> > * WScript.Echo
> > * WScript.Echo "=========================================="
> > * WScript.Echo "Computer: " & strComputer
> > * WScript.Echo "=========================================="
>
Quote:

> > Set objWMIService = GetObject("winmgmts:\\" & strComputer _
> > * *& "\root\CIMV2\Security\MicrosoftVolumeEncryption")
> > Set volumes = objWMIService.InstancesOf("Win32_EncryptableVolume")
>
Quote:

> > for each volume in volumes
> > * *If volume.DriveLetter = "C:" then
> > * *retval = volume.GetEncryptionMethod(em)
> > * *WScript.Echo em
> > * *End If
> > Next
> > Next
>
Quote:

> > <---------- End Script -------------------->
>
Quote:

> > Note that I was only interested in the C: drive, hence the "If
> > volume.DriveLetter "
>
Quote:

> > OldDog
>
> Finally, a real, working demo of Win32_EncryptableVolume. : )
>
> Do GetProtectionStatus and GetConversionStatus work correctly with this as
> well now? I wasn't sure if the problem was using ExecQuery to get the
> instance references.- Hide quoted text -
>
> - Show quoted text -

They both come up with the numbers I am expecting.

But to add to the fun, GetConversionStatus() has a property called
EncryptionPercentage which would be nice to have. Any ideas there?

OldDog
My System SpecsSystem Spec
Old 05-06-2009   #7 (permalink)
Alex K. Angelopoulos


 
 

Re: How do you call a method?



"OldDog" <mikef2691@xxxxxx> wrote in message
news:8b9b1709-ea73-49c6-ae48-99af6fa9dc11@xxxxxx
Quote:

> On May 6, 11:50 am, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
Quote:

>> "OldDog" <mikef2...@xxxxxx> wrote in message
>>
>> news:5bc08f69-11c0-4639-a57e-c281757f3b84@xxxxxx
>>
>>
>>
>>
>>
Quote:

>> > On May 6, 8:45 am, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
>> > Thanks, Alex. That works like a charm. Here is my script;
>>
Quote:

>> > dim retval, em
>> > arrComputers = Array(".")
>> > For Each strComputer In arrComputers
>> > WScript.Echo
>> > WScript.Echo "=========================================="
>> > WScript.Echo "Computer: " & strComputer
>> > WScript.Echo "=========================================="
>>
Quote:

>> > Set objWMIService = GetObject("winmgmts:\\" & strComputer _
>> > & "\root\CIMV2\Security\MicrosoftVolumeEncryption")
>> > Set volumes = objWMIService.InstancesOf("Win32_EncryptableVolume")
>>
Quote:

>> > for each volume in volumes
>> > If volume.DriveLetter = "C:" then
>> > retval = volume.GetEncryptionMethod(em)
>> > WScript.Echo em
>> > End If
>> > Next
>> > Next
>>
Quote:

>> > <---------- End Script -------------------->
>>
Quote:

>> > Note that I was only interested in the C: drive, hence the "If
>> > volume.DriveLetter "
>>
Quote:

>> > OldDog
>>
>> Finally, a real, working demo of Win32_EncryptableVolume. : )
>>
>> Do GetProtectionStatus and GetConversionStatus work correctly with this
>> as
>> well now? I wasn't sure if the problem was using ExecQuery to get the
>> instance references.- Hide quoted text -
>>
>> - Show quoted text -
>
>
> They both come up with the numbers I am expecting.
>
> But to add to the fun, GetConversionStatus() has a property called
> EncryptionPercentage which would be nice to have. Any ideas there?
>
> OldDog
Yep. You just define variables for both conversionstatus and
encryptionpercent, then pass them in as parameters.

dim cs, ep

retval = volume.GetConversionStatus(cs, ep)
WScript.Echo cs
WScript.Echo ep




My System SpecsSystem Spec
Old 05-07-2009   #8 (permalink)
OldDog


 
 

Re: How do you call a method?

On May 6, 6:22*pm, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
Quote:

> "OldDog" <mikef2...@xxxxxx> wrote in message
>
> news:8b9b1709-ea73-49c6-ae48-99af6fa9dc11@xxxxxx
>
>
>
>
>
Quote:

> > On May 6, 11:50 am, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
Quote:

> >> "OldDog" <mikef2...@xxxxxx> wrote in message
>
Quote:
Quote:

> >>news:5bc08f69-11c0-4639-a57e-c281757f3b84@xxxxxx
>
Quote:
Quote:

> >> > On May 6, 8:45 am, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
> >> > Thanks, Alex. That works like a charm. Here is my script;
>
Quote:
Quote:

> >> > dim retval, em
> >> > arrComputers = Array(".")
> >> > For Each strComputer In arrComputers
> >> > * WScript.Echo
> >> > * WScript.Echo "=========================================="
> >> > * WScript.Echo "Computer: " & strComputer
> >> > * WScript.Echo "=========================================="
>
Quote:
Quote:

> >> > Set objWMIService = GetObject("winmgmts:\\" & strComputer _
> >> > * *& "\root\CIMV2\Security\MicrosoftVolumeEncryption")
> >> > Set volumes = objWMIService.InstancesOf("Win32_EncryptableVolume")
>
Quote:
Quote:

> >> > for each volume in volumes
> >> > * *If volume.DriveLetter = "C:" then
> >> > * *retval = volume.GetEncryptionMethod(em)
> >> > * *WScript.Echo em
> >> > * *End If
> >> > Next
> >> > Next
>
Quote:
Quote:

> >> > <---------- End Script -------------------->
>
Quote:
Quote:

> >> > Note that I was only interested in the C: drive, hence the "If
> >> > volume.DriveLetter "
>
Quote:
Quote:

> >> > OldDog
>
Quote:
Quote:

> >> Finally, a real, working demo of Win32_EncryptableVolume. : )
>
Quote:
Quote:

> >> Do GetProtectionStatus and GetConversionStatus work correctly with this
> >> as
> >> well now? I wasn't sure if the problem was using ExecQuery to get the
> >> instance references.- Hide quoted text -
>
Quote:
Quote:

> >> - Show quoted text -
>
Quote:

> > They both come up with the numbers I am expecting.
>
Quote:

> > But to add to the fun, GetConversionStatus() has a property called
> > EncryptionPercentage which would be nice to have. Any ideas there?
>
Quote:

> > OldDog
>
> Yep. You just define variables for both conversionstatus and
> encryptionpercent, then pass them in as parameters.
>
> dim cs, ep
>
> retval = volume.GetConversionStatus(cs, ep)
> WScript.Echo cs
> WScript.Echo ep- Hide quoted text -
>
> - Show quoted text -
Too cool. Thanks.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Dont undertstand how this method call really works... PowerShell
how to call a static method in a .net class from powershell? PowerShell
you can not call a method on null-valued expression PowerShell
You cannot call a method on a null-valued expression PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46