From: rich.green on
Hi,

I'm in the process of learning soem basic scripting from tutorials etc,
and have borrowed the following script from a couple of MS technet
pages:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
&
"'Win32_Directory.Name=""c:\\\\progra~1\scopet~1\mobile~1\outbound""'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "source_address"
objEmail.To = "destination_address"
objEmail.Subject = "test message"
objEmail.Textbody = "A new file has been detected in [directory]."
objEmail.Send

Loop


I'm getting a parsing error which I strongly suspect is coming from:

&
"'Win32_Directory.Name=""c:\\\\progra~1\scopet~1\mobile~1\outbound""'")


but I just can't seem to get the syntax right. As you can see, in the
example I'm trying to use short names, with no luck. the full path I'm

specifying is

C:\Program Files\Scope Technologies\Mobile Interface\Outbound

If anybody could offer advice, it would be *greatly* appreciated.

Thanks,
Rich

From: Dumb Luck on
Try using long file names and double slashes, like this:
"'Win32_Directory.Name=""c:\\\\Program Files\\Scope
Technologies\\Mobile Interface\\Outbound""'")

From: rich.green on
Hi, I've tried this, and I get a WSH error

Line: 5
Char: 1
Error: Invalid Query
Code: 80041017
Source: SWbemServicesEX

From: Jonathan Liu [MSFT] on
Try this:

Set colMonitoredEvents = objWMIService.ExecNotificationQuery ("SELECT * FROM
__InstancecreationEvent WITHIN 1 WHERE Targetinstance ISA
""CIM_DirectoryContainsFile"" and TargetInstance.GroupComponent=
""c:\\progra~1\\scopet~1\\mobile~1\\outbound""")

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


<rich.green(a)gmail.com> wrote in message
news:1138721643.251853.194570(a)g47g2000cwa.googlegroups.com...
> Hi, I've tried this, and I get a WSH error
>
> Line: 5
> Char: 1
> Error: Invalid Query
> Code: 80041017
> Source: SWbemServicesEX
>


From: rich.green on
Thanks for the reply Jonathan, I tried this and still got a parsing
error. In the end i've worked around the problem by defining a drive
using the 'subst' command, and referring to the drive letter rather
than the path. A little dirty but will do the trick.

Cheers,
Rich