Jump to content

Recommended Posts

Posted

I need to search a share for desktop.ini and for each desktop.ini I find and need to change the ntfs permissions to remove the read attribute from this file. I am fine with the xcalcs part, its the script to search with the share eg \\server\users$ for desktop.ini.

 

Any ideas or help would be much appreciated!

Posted

If you map a drive to the share and move to the root of that mapped drive, then something like(!) this simple DOS command ought to work:

 

ATTRIB -R "desktop.ini" /S

Posted

Sadly I am not able to map a drive as I need to run it as a vbscript on login. Also would that command just remove the administrators read permission or all users as I only need to remove the administrators read permissions.

 

Thank you for the suggestion tho

Posted (edited)

::ignore me:: I thought you meant the read-only attribute (even though you'd said ntfs) not the read ACE (access control entry).

 

So do you basically want to stop desktop.ini having any effect on Administrator logons?

Edited by PiqueABoo
Posted
Yer basically.. I want the desktop.ini in the users folders to not be read by the administrator. IE Server 2008 and Win7 on folder redirection renames \\server\users$\Bob to \\server\users$\Documents. One of microsofts solutions is to remove read attribute on desktop.ini to the administrator. As the renaming is just the display name. I know best practice is to put \\server\users$\bob\Documents but at the moment I am unable to do this.
Posted
does it have to be a vbscript - could you not use windows to search for all the desktop ini files in that shared directory and once it has found all of them, select all of them and right click and click properties which should go to the properties of all of them and you should be able to remove the ready only property that way ( I think - could be wrong )
Posted

This isn't easy :-(

What you want to do is:

Set oShell = WScript.CreateObject("WScript.Shell")
Set oSpecialFolders = oShell.SpecialFolders
sMyDocs=oSpecialFolders("MyDocuments")
sINI=sMyDocs & "\desktop.ini"
scmd="cacls " & sINI & " /e /r administrators"
oShell.run sCmd,,true

as part of the user login script. What this does is find the location of "my documents" (it will return \\server\users$\username or whatever the redirected location is). It then works out the full path name for desktop.ini and builds a command to run cacls on it.

 

So far, so good ...

 

It all falls over because you'll get "access denied" when you try and run cacls - even though a normal user will have permission to reset the permissions on the file, UAC will prevent this from running.

 

I'd guess what you're trying to do is stop having hundreds of folders all of which appear to be called "documents" so let's change the desktop.ini content so that it does just that - what we want is to make each folder show the user name.

 

Plan B:

on error resume next
set oFSO=createobject("scripting.filesystemobject")
Set oShell = WScript.CreateObject("WScript.Shell")
set oNet=wscript.createobject("wscript.network")
'get the name of the logged on user
sUser=oNet.username
'find the "mydocs" directory
Set oSpecialFolders = oShell.SpecialFolders
sMyDocs=oSpecialFolders("MyDocuments")
'and the desktop.ini
sINI=sMyDocs & "\desktop.ini"
'delete it if it's there (true forces delete)
if ofso.fileexists(sINI) then ofso.deletefile sINI,true
'create it. "True" says overwrite if present - belt and braces!
set oFile=ofso.createtextfile(sIni,true)
'write the content
oFile.writeline "[.ShellClassInfo]"
oFile.writeline "LocalizedResourceName=" & sUser
oFile.close

 

 

I think you could actually stop after the delete statement - you then won't have a desktop.ini and Windows will just show the username for each folder (because that's what the folder is called!) but this just puts in a desktop.ini containing what you want. You could add more - eg you could add an icon, you could look up the user's full name and so on - but hopefully this will work for the basics you need.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...