Script that deletes file from XP roaming profile -- needs refinement

Posted on 2012-09-10
Last Modified: 2012-09-11
I'd like for someone to take a look at the code below (which I've pieced together from an example script that I once found).  It loads via Group Policy as a "logon script".

It works properly in that it deletes one specific file after waiting 9 seconds.  In case you're wondering, I can't exclude this entire directory from users' roaming profiles, but this self-generating 9MB help file creates unnecessary panic as the "exceeded roaming profile storage space limit" pops up prematurely.

HOWEVER, it needs some refining because occasionally users complain about an "activex component can't create object 'scripting.filesystemobject' " while their deskop is loading.  They click OK and everything is fine, except it's a nuisance issue for me.

Dim fso, fld, subf

Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder("c:\Documents and Settings")

On Error Resume Next


For Each subf In fld.SubFolders
    fso.DeleteFile "c:\Documents and Settings\" & subf.Name & "\Application Data\ShoreWare Client\Help_17_61_4706_0.pdf"

Set subf = Nothing
Set fld = Nothing
Set fso = Nothing

Open in new window

Question by:Elmo_Oxygen
    1 Comment
    LVL 77

    Accepted Solution

    why not just a batch file
    > "%Temp%.\sleep.vbs" ECHO WScript.Sleep 9000
    CSCRIPT //NoLogo "%Temp%.\sleep.vbs"
    DEL "%Temp%.\sleep.vbs"
    del "%appdata%\ShoreWare Client\Help_17_61_4706_0.pdf"

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
    Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  ( Here (http…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now