At url
http://www.microsoft.com/technet/scriptcenter/guide/sas_fil_lifi.mspx
there is a sample script (Listing 11.29 Monitoring File Creation). In
it, the author uses a literal to name the folder path he/she wants to
watch. I would like to supply this script with a command line argument
to be assigned to a variable and used in place of the literal. But I
am having a terribly hard time figuring out how to do that.

Any help would be appreciated.

Dennis Glover

Re: Nested quotations in WMI/VBScript/WQL Select by LakeGator

LakeGator
Wed Nov 30 19:41:19 CST 2005

' Modification of script center example of use
' optional command line arguments for:
' - folder (defaults to c:\\\\scripts)
' - computer (defaults to . - localhost)
'
If Wscript.Arguments.Count > 0 Then
strFolder = Wscript.Arguments.Item(0)
Else
strFolder = "c:\\\\scripts"
End If
If Wscript.Arguments.Count > 1 Then
strComputer = Wscript.Arguments.Item(1)
Else
strComputer = "."
End If
'
Wscript.Echo "Monitoring \\" & strcomputer & "\" & strFolder & " . . ."
'
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=""" & strFolder & """'")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo objLatestEvent.TargetInstance.PartComponent
Loop

' Enjoy