Forcing deletion of folder with ReadOnly files.

Home Forums Scripting General Scripting Forcing deletion of folder with ReadOnly files.

Viewing 1 post (of 1 total)
  • Author
  • Avatar

    Hello World

    I’m trying to complete this: I need to delete
    documents & settingsusernamelocal settingstemp
    folder at computer startup and I’m implementing this via GPO.

    My peice of code is:

    set oFS = CreateObject(“Scripting.FileSystemObject”)
    set oWSH = CreateObject(“WScript.Shell”)

    ‘gets the last logged on user
    sLastUser = oWSH.RegRead (“HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogonDefaultUserName”)
    ‘set path
    sTempPath = “c:Documents and Settings” & sLastUser & “Local SettingsTemp”

    ‘delete entire folder

    Everything works fine, except when inside TEMP folder there are Read-Only files.
    In that case I receive an Access Denied during computer startup.
    Is there a way to force deletion for RO files (or anso for locked files) so that deletion is surely completed?

    Thanks so much

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.