+ Post New Thread
Results 1 to 11 of 11
Scripts Thread, Help someone with limited VB Knowledge please! in Coding and Web Development; I need to search a share for desktop.ini and for each desktop.ini I find and need to change the ntfs ...
  1. #1

    Join Date
    Feb 2010
    Posts
    17
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Help someone with limited VB Knowledge please!

    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!

  2. #2

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    114
    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

  3. #3

    Join Date
    Feb 2010
    Posts
    17
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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

  4. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,217
    Thank Post
    2,769
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    vb what ? 6, 2008 ???

  5. #5

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    114
    ::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?
    Last edited by PiqueABoo; 29th June 2010 at 07:39 PM.

  6. #6

    Join Date
    Feb 2010
    Posts
    17
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Vbscript server 2008...

  7. #7

    Join Date
    Feb 2010
    Posts
    17
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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.

  8. #8

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,217
    Thank Post
    2,769
    Thanked 935 Times in 875 Posts
    Rep Power
    343
    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 )

  9. #9

    Join Date
    Feb 2010
    Posts
    17
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I need it to be automated as the desktop.ini is likely to be replaced everytime a machine sync's there offline files.

  10. #10

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,144
    Thank Post
    113
    Thanked 518 Times in 447 Posts
    Blog Entries
    2
    Rep Power
    121
    This isn't easy :-(
    What you want to do is:
    Code:
    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:
    Code:
    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.

  11. Thanks to srochford from:

    cwade100 (29th June 2010)

  12. #11

    Join Date
    Feb 2010
    Posts
    17
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Will have a play

SHARE:
+ Post New Thread

Similar Threads

  1. Site: Jorge 's quest for knowledge!
    By DaveP in forum RSS Feeds
    Replies: 0
    Last Post: 15th June 2010, 08:00 AM
  2. Example Knowledge Base Articles
    By linkazoid in forum How do you do....it?
    Replies: 0
    Last Post: 21st October 2009, 11:58 AM
  3. General Knowledge
    By neilmc in forum General Chat
    Replies: 19
    Last Post: 27th August 2009, 03:19 PM
  4. Wikifying Thin Client Knowledge
    By Ric_ in forum Thin Client and Virtual Machines
    Replies: 5
    Last Post: 7th April 2008, 11:22 PM
  5. sims.net knowledge
    By danIT in forum MIS Systems
    Replies: 6
    Last Post: 29th January 2007, 07:04 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •