The Query Id attribute must be numeric. I got the following to work:
for (10000..10001) { die Win32::OLE->LastError() unless (push @Triggers, $TriggerSet->C +reate(0)); $Triggers[$#Triggers]->{Id} = $_; $Triggers[$#Triggers]->{Subscription} = qq{<QueryList> <Query Id="$_" Path="Microsoft-Windows-NetworkProfile/Operat +ional"> <Select Path="Microsoft-Windows-NetworkProfile/Operational +">*[System[(EventID="$_")]]</Select> </Query> </QueryList>}; die Win32::OLE->LastError() unless (my $values = $Triggers[$#Triggers]->ValueQueries->Create("ev +entId", "Event/System/EventID")); $Triggers[$#Triggers]->{Enabled} = 1; }
The relevant, magic change is matching
and$Triggers[$#Triggers]->{Id} = $_;
Maybe you can change both to be non-numeric, but with that change, I created tasks that I was able to view them afterwards.<Query Id="$_" Path="Microsoft-Windows-NetworkProfile/Operational" +>
Some stylistic notes:
Don't use double-quoted strings with (many) escaped backslashes in them. Instead, use one of the alternate quoting mechanisms, like qq{...} to prevent excessive backslashitis.
For easier testing, do both calls at the end of your program:
warn "Testing query"; $RootFolder->RegisterTaskDefinition("OLE-Test",$TaskDefinition,1,undef +,undef,3); warn "Query OK, installing task"; $RootFolder->RegisterTaskDefinition("OLE-Test",$TaskDefinition,6,undef +,undef,3); print Dumper $TaskDefinition->{XmlText};
In reply to Re: Win32::OLE and Task Scheduling - Invalid Query
by Corion
in thread Win32::OLE and Task Scheduling - Invalid Query
by kambe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |