Re: Help a newbie with this VBScript

From: Jonas Sackerud (jonas.sackerud_at_seaflex.net)
Date: 04/02/04


Date: Fri, 2 Apr 2004 08:00:48 +0200

I can't thank you enough Stivie. This saves me both time and money. Good
work!

"Stivie S." <stefan.suesser@computacenter.com> skrev i meddelandet
news:B09C5EEC-E24D-4B25-A9A8-6CA04FCEDFEE@microsoft.com...
> Hi Jonas,
>
> you can easily modify the script to run indefinitely - until you terminate
it manually or log off. Just put a "DO...LOOP" statement around the line
that gathers the event. Here's how:
>
> strComputer = "."
> IomegaModelID = "IC35L090 AVV207-0 USB Device"
> Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
> Set Events =
GetObject("winmgmts:\\.\root\cimv2").ExecNotificationQuery("SELECT
TargetInstance.Model " _
> & "FROM __InstanceCreationEvent WITHIN 5 " _
> & "WHERE TargetInstance ISA 'Win32_DiskDrive' and " _
> & "TargetInstance.InterfaceType='USB' and ") _
> & "TargetInstance.Model='" & IomegaModelID & "'")
>
>
> DO
> Set DiskEvent = Events.NextEvent
> Wscript.Echo "USB drive connected: " &
DiskEvent.TargetInstance.Model
> LOOP
>
> You can read a nice description of scripting WMI events in the Windows
2000 Scripting Guide on TechNet. Here is the link to the WMI event
documentation:
>
http://www.microsoft.com/resources/documentation/windows/2000/server/scriptguide/en-us/sas_wmi_kzcp.mspx
>
> When you want to run this WMI event consumer all the time, then I would
recommend that you install a permanent event consumer. The MSDN library
contains nice documentation how you create and compile a permanent event
consumer using the "ActiveScriptEventConsumer". In short: you create a MOF
file that contains the code for your event consumer, then compile this MOF
using "mofcomp.exe". By this, the event consumer will be compiled in your
WMI repository so that you do not have to start the script yourself. Here's
the link to the MSDN documentation:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/running_a_script_based_on_an_event.asp
>
> Hope this helps...



Relevant Pages

  • RE: Starting Excel and doing "stuff"...
    ... I have a WMI .vbs that monitors a folder for new files. ... This code first creates an event filter that polls the repository every 5 ... can use another script or utilities like wbemtest.exe or CIM Studio). ... Active script event consumer has limitations, you can't make Excel visible, ...
    (microsoft.public.excel.programming)
  • Re: question about compiling Expect script with freewrap: invalid command spawn
    ... > I want to compile my scripts for distribution. ... and then compiled one of my little script. ... does freewrap only support TCL ... when I run the file with error parameters, ...
    (comp.lang.tcl)
  • Re: long double in C89?
    ... >> compile time for conforming to any standard (no equivalent of ... Oh, I do (I use GNU autoconf which generates a 'configure' script, ... environment (or at least a Bourne shell equivalent and several standard ...
    (comp.lang.c)
  • Re: compiling dcraw, a raw file to ppm convertor
    ... I'm using dcraw -4 to convert to a liniar ppm image now then converting it ... I want my script to produce file names ... GNU Humour 'Technical Thug' ... > Compile your own libjpeg and compile the app against that instead of ...
    (comp.sys.sgi.admin)
  • Re: Massive Memory Structures
    ... (Solaris on sparc, Solaris on x86_64) ... script, I get an out of memory error and the script dies. ... what options do I need to compile in to make this happen. ... It will create a 5g test file, ...
    (comp.lang.perl.misc)