Posted on 2007-10-10
Last Modified: 2010-04-16
I am looking to write a script that would run on weekends only to delete all temp files on our file servers. So the script would need to be triggered to run without manual intervention.
Question by:SuperFly07
    LVL 1

    Expert Comment

    You don't need vbscript for this, just a batch file will do:

    del c:\temp\*.* /y
    del c:\windows\temp\*.* /y

    Put those lines in deltemp.bat, change the directories to whatever you need cleared, and make the .bat file a scheduled task on the server for whenever you prefer on the weekend.
    LVL 65

    Accepted Solution

    You may be better off running

    RD C:\Temp /s /q
    MD C:\Temp
    RD C:\Windows\Temp /s /q
    MD C:\Windows\Temp

    which will delete all subfolders from those Temp folders as well.



    Author Comment

    Out fileserver is my X-drive. Can we write a script that would clean all temp files from X drive? Reason being temp files can be scattered all over the place.
    LVL 1

    Assisted Solution

    Perhaps you could tell us what "temp" files means to you?  Are you saying files that end in *.tmp ?  

    If so, then your batch file could just be:

    del x:\*.tmp /s /q

    That will do the root of X: and all subdirectories, and delete all files ending in .tmp without prompting you for anything.
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    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…
    This article will show, step by step, how to integrate R code into a R Sweave document
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    794 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

    15 Experts available now in Live!

    Get 1:1 Help Now