Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating WMI Filter to detect folder

Status
Not open for further replies.

gmail2

Programmer
Jun 15, 2005
987
IE
I want to create a WMI filter that will check for a certain directory. if the directory exists then the policy will apply certain permissions to that directory. This is the query I've written so far but it doesn't work:
Code:
SELECT * FROM CIM_DirectorySpecification WHERE DirectoryPath LIKE "%ProgramFiles%\\eCopy\\Desktop"
I've put in double backslashes to escape the first one because when I put in single ones it gives an error. However, having refreshed the policy on the PC's that DO have that directory, when I run gpresult it says the policy was not applies because of the filter - meaning obviously my query is not correct. Can somebody help me figure out how this should be written?

 
Wouldn't it be easier to just use a logon script batch with something like:

Code:
If Exist %ProgramFiles%\eCopy\Desktop (
cacls %ProgramFiles%\eCopy\Desktop /T /G "Domain Admins":F
)

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Good Suggestion but there are 2 problems.

1. A logon script gets run as the user - at the moment the user does not have rights to change permissions on anything in that directory so there's no way to change permissions using logon script.

2. When this domain was created (before I joined the company) somebody put %ProgramFiles% as read only through group policy. I don't want to remove this as this person is my Manager - so the only way to get around it is to also apply these permissions through group policy.

Any ideas why my query doesn't work?
 
Can anybody help out with the syntax for my query at all?
 
Just wanted to mention that I resolved this problem. Rather than using a GPO, I created a new group and added the PC's with this software into that group. Then I just gave that group permissions to apply settings from the newly created polciy and it worked. Of course this is OK in this environment because the software is only instaled on 5 dedicated PC's but in an environemnt where software is installed / uninstalled all the time it wouldn't work so well
 
The only way I could get it to work was something like this...

Code:
Select * from Win32_Directory where Drive = 'c:' and FileName = 'eCopy'

I think that your final solution is probably better.

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top