Re: Help a newbie with this VBScript

From: Jonas Sackerud (
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

"Stivie S." <> skrev i meddelandet
> 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 &
> Set Events =
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: " &
> 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
> 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:
> 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, ...
  • 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, ...
  • 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 ...
  • 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 ...
  • 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, ...