Using environment variables in a wmi query


hello

i'm trying use wmi queries on group policy preferences targeting computers on network.

have file named testfile.txt in windows directory , check last modified date replace policy files if date older of current file.

set query : select * cim_datafile name='c:\\windows\\testfile.txt' , lastmodified<'20140910145110.821214+180'.

replace action occurs on machines windows directory 'c:\windows\'. there machines on network windows installed on directory 'c:\windows7'.

thinking use %windowsdir% environment variable in wmi query ckeck testfile.txt date on correct directory windows installed.

i've tried different ways use environment variable in wmi query no success (for example: select * cim_datafile name='%windowsdir%\\testfile.txt' , lastmodified<'20140910145110.821214+180').

can me correct syntax?

thanks.


> set query : select * cim_datafile where
> name='c:\\windows\\testfile.txt' and
> lastmodified<'20140910145110.821214+180'.
>
> replace action occurs on machines windows directory is
> 'c:\windows\'. there machines on network windows is
> installed on directory 'c:\windows7'.
>
> thinking use %windowsdir% environment variable in wmi
> query ckeck testfile.txt date on correct directory windows
> installed.
 
short answer: cannot use environment variables in wmi filters.
 
but can modify query:
 
select * cim_datafile (name = 'c:\\windows\\testfile.txt' or
name = 'c:\\windows7\\testfile.txt' ) ,
lastmodified<'20140910145110.821214+180'
 
event 1 should work:
 
select * cim_datafile name 'c:\\windows%\\testfile.txt'
and lastmodified<'20140910145110.821214+180'
 
btw: variable should %windir% anyway, not %windowsdir% :)
 

martin

mal ein gutes buch über gpos lesen?

no not evil, if know doing: or bad gpos?
, if bothers me - coke bottle design refreshment :))


Windows Server  >  Group Policy



Comments

Popular posts from this blog

Azure MFA with Azure AD and RDS

Failed to setup initiator portal. Error status is given in the dump data.

Invalid pointer on gpresult /h gpreport.html