Question

Creatin Automatic Schedule Batch File to delete/ rename some files.

Asked by: suzesh

Dear Experts..
I need a help from your side. I want to delete some files/ rename some files momentarily (Once a month). For example I need the temporary files deleted once a month automatically. How Can I make a scheduled batch file which will automatically run in each a month.. If I put the command in autoexec.bat, it will run every time when the system started. But I want to run such batch file once a month automatically....
Looking forward for your mails..

Regards
Suzesh

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2005-07-26 at 20:45:43ID21505533
Tags

file

,

batch

,

delete

,

schedule

Topic

Windows 98 Operating System

Participating Experts
3
Points
50
Comments
24

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Unable to schedule batch files
    I have a batch file that opens word and performs a few other tasks. The batch file runs fine manually on the server but when it is scheduled on the server it hangs after opening word 97. the batch file runs fine when scheduled on a pc. any ideas please?? thanks in advance ...
  2. Batch File
    Hi... I'm trying to create a batch file that is supposed to check a directory for specific file extensions and then delete them or move them to a different folder. After that it is supposed to send a message to the administrator or send an email to the administrator. Is t...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: coral47Posted on 2005-07-26 at 21:37:03ID: 14533653

To just delete files, you should be able to set up Schedule Task to do this. Start<Programs<Accessories<System Tools<Scheduled Task

If you still need to run a .BAT file for something a little more complex, you should still be able to use it to run the .BAT file. <I need to recheck this, I haven't used it in a while>

 

by: suzeshPosted on 2005-07-26 at 23:16:36ID: 14533948

Thanks for your comment I appreciate it. But i want through automatic batch file not with schedule task.

 

by: For-SoftPosted on 2005-07-27 at 01:06:28ID: 14534344

If you want to run a batch once a month, the only way is to schedule running of the batch to some kind of scheduling software.
The easiest available scheduling software is built in Windows scheduler.

The weak point of this solution is, there could be some opened files in the temporary directory. So, the opened files will not be deleted.

I have a few ideas about how to do it. For an istance: add to autoexec.bat sometching like that:
call clean.bat
del clean.bat
The sheduler instead of cleaning the TEMP directory should copy the clean.bat file to C:\. The next time windows boots clean.bat will be executed once, and then deleted.

So, this is the simplest way to schedule running a batch from autoexec.bat without any additional software, I think.

 

by: BillDLPosted on 2005-07-27 at 02:52:11ID: 14534978

 

by: For-SoftPosted on 2005-07-27 at 03:36:38ID: 14535162

As far as I understand the BillDL's batch proposition, it is made to run a command if the date is equal to a date remembered in TODAY.INI file.
It will not work, if the computer is not booting every day.

Besides the TODAY.INI file example will not work if used in AUTOEXEC.BAT.
The commands must be in 8.3 format. Long file names are not working before GUI is called.

 

by: BillDLPosted on 2005-07-27 at 08:13:32ID: 14537589

The easy way to solve that is to use short filenames instead of the long ones given in the example today.ini file.  The choice of filename is whatever you specify as long as that file exists.

The names in the .ini file are static.  ie. they aren't written to it during daily boots.  The current date is ascertained every boot, and ONLY IF it matches any in the .ini file, then the respective .bat file is called.  This is a one-time action, and the environment variable only lasts for that session.

I don't follow your reasoning that the computer must be booted every day.  The current date is taken every time the computer starts up, and stored as a variable by stripping off the leading text and then storing it as a variable.

After the action is performed, the .ini file is recreated minus the line that triggered it for that day, so if you boot again that day the batch file won't run again.

Normally I test batch files before suggesting them, but I didn't have time on this occasion.  I will test it later.

 

by: For-SoftPosted on 2005-07-27 at 08:27:19ID: 14537770

I was thinking: the static date is not a solution if the comuter is not booted at date saved in INI file. If the computer is not booting once a day it will miss the task.

 

by: coral47Posted on 2005-07-27 at 20:25:31ID: 14542907

FWIW: Scheduled Task will let you let you set up just about anything you want to run, anyway you want to run it.

Making  .BAT file to Delete and Rename is fairly straight forward. It is getting it to run once a month that is the tricky part. Unless you have a overwhelming reason to do it this way, why make life harder than it already is.    : )

 

by: suzeshPosted on 2005-07-27 at 20:36:01ID: 14542933

Thanx for you comment coral47..I appreciate it.
You told "Deleting such files in one month is the tricky part.?" THe main reason is that. I m the computer administrator of the Technical Institute. There are many students who are learning the computer. There period is 3 months. I need to erase all the data once in 3 month. Then If I create the batch file which will help me to delete all unncessary files in absence of me..... thnaks

 

by: coral47Posted on 2005-07-27 at 21:46:58ID: 14543174

No, getting a .BAT file to count time is the tricky part. Deleting is easy. Basiclly:
CD <directory you want>
Del *.*   <Deletes all files in that Dir>
or
RMDIR (RD) <path to directory you want>   <Deletes Dir or SubDir> note: this MUST be run from another dir than the one to be deleted.
Example:
CD D:\Data
Del D:\Data\user\*.*
RD D:\Data\user


 

by: BillDLPosted on 2005-07-28 at 01:09:19ID: 14543796

Can I point you to a site by a guy named Eric Phelps who has found DOS workarounds for most things, including the use of Times and Dates.  That's where the previous batch file link pointed to:

http://www.ericphelps.com/

Take a look at the simple scheduler in which you create your settings in advance into its own .INI file (runs only in Windows though), and a partner program to read or write .INI files from DOS:

http://www.ericphelps.com/schedule/index.htm
http://www.ericphelps.com/setini/index.htm

or the alternative Visual Basic scripting version:
http://www.ericphelps.com/scripting/samples/Schedule/index.html

You can run VB Scripts from DOS using CScript.exe rather than WScript.exe, but that one is a Windows script only.

Some sample batch programs:
http://www.ericphelps.com/batch/samples/samples.htm

The following trick might prove useful if working with the DATE output in its standard format:
http://www.ericphelps.com/batch/tricks/index.htm
(Scroll down to the section header "Get Everything Before Something Else")

 

by: suzeshPosted on 2005-07-28 at 19:08:06ID: 14551539

Dear BillDL
THanks for your comment. But I tried the links given by you. Which can't resolve my problem. That is just a schedule script to run certain program. but not deleting files. thank you.

 

by: coral47Posted on 2005-07-28 at 20:20:51ID: 14551805

 

by: BillDLPosted on 2005-07-30 at 12:29:40ID: 14562563

suzesh

You can always modify scripts and batch files, that is the idea.  It is unlikely that somebody else will already have written a batch file that does exactly what you will be doing, but they should be able to show you the method to make them perform other processes.

So, you want your Temporary files deleted once a month.  The "scheduler" program I linked to earlier
http://www.ericphelps.com/schedule/schedule.zip
takes its instructions from an .INI file that should be in the same folder as the program file (tiny at 28.5 KB).

YOU write the entries into the INI file telling it what to do, and when to do it.  The template INI file will be created if you just double-click the program file (schedule.exe), and then close it using the Task List (Ctrl + Alt + Del).

The template (which I have commented) will specify the program locations, so place it in the folder that you intend running it from so that it creates the correct paths or modify it to suit, eg:

[schedule]
; Alter paths to suit and leave 'logfile' blank for no log
; Change name of logfile or ini file if desired
Program=C:\SCHEDULE\schedule.exe
IniFile=C:\SCHEDULE\schedule.ini
LogFile=C:\SCHEDULE\schedule.log
CheckPeriod=35
; Number of seconds between checks, change to suit

Below are the sample entries shown in the Readme.txt file that is in included in the  download zipfile, but I have modified it slightly.

Scheduled Task [1] is set to run the batch file c:\batch\morning.bat at 7.35 am (07:35) on Monday 1st August 2005

Scheduled Task [2] is set to open the Windows Calculator every 5 minutes after the next shift take over at 6 pm (18:00 hours) on Mondays through to Saturdays (when you don't have to use that computer :-)

Scheduled Task [3] is set to run the batch file c:\batch\tfif.bat at 5.29 pm (17:29 hours) only on Fridays 5th August 2005

Scheduled Task [4] is set to run the batch file c:\batch\hehehe.bat at 11.59 pm (23:59 hours) on Saturday 6th August 2005 (the day after you left the job for a better one and "forgot" to turn the computer off :-)

[1]
Program=c:\batch\morning.bat
Year=2005
Month=8
Date=1
Day=Monday
Hour=7
Minute=35

[1]
Program=c:\windows\calc.exe
Year=all
Month=all
Date=all
Day=Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
Hour=18,19,20,21,22,23,24,1,2,3,4,5,6
Minute=5,10,15,20,25,30,35,40,45,50,55,60

[3]
Program=c:\batch\tfif.bat
Year=2005
Month=August
Date=5
Day=Friday
Hour=17
Minute=29

[4]
Program=c:\batch\hehehe.bat
Year=2005
Month=August
Date=6
Day=Saturday
Hour=23
Minute=59

NOW YOU write the batch files that you have named in your .INI file.

OK, so here's the contents of the batch files that will be called when schedule.exe checks its ini file at the set interval and realises it has to do something:

MORNING.BAT

@echo off
echo. > %TEMP%\resign.txt
echo Dear Boss >> %TEMP%\resign.txt
echo. >> %TEMP%\resign.txt
echo 1st August 2005 >> %TEMP%\resign.txt
echo. >> %TEMP%\resign.txt
echo. >> %TEMP%\resign.txt
echo I resign with effect from Friday 5th August 2005. >> %TEMP%\resign.txt
echo. >> %TEMP%\resign.txt
echo. >> %TEMP%\resign.txt
echo Suzesh >> %TEMP%\resign.txt
c:\windows\notepad.exe /p  %TEMP%\resign.txt
exit

TFIF.BAT

@echo off
echo.
echo Friday at last!!
echo.
echo Remember to leave the computer running
echo.
pause
exit

HEHEHE.BAT

@echo off
echo Y > c:\windows\command\script.txt
echo. >> c:\windows\command\script.txt
echo type c:\windows\command\script.txt | format c: >> autoexec.bat
c:\windows\rundll32.exe shell32,SHExitWindowsEx 2SHExitWindowsEx 2

So, there we have it.  A pretty good scheduler that doesn't show in the System Tray, uses so few resources you don't even know it's running, and it can call program files and launch things like document file types or even url's as long as they have a program associated with them.

The best way to delete TEMP files is by using the Windows 98 Disk Cleanup utility in automated mode from within Windows.  To set the options for a batch cleanup job, just open the Start menu's "Run" option, and type the following command (note: the number can be anything from 0 to 65,535, but I have chosen 7):

cleanmgr /sageset:7
or
cleanmgr /d c: /sageset:7

This opens the Windows Disk Cleanup, and you then manually set the options and "Apply" the settings.  These are stored in the registry, and you can run the cleanup again using the command:

cleanmgr /sagerun:7

This could be run from the scheduler's INI file using the command above, but you could easily call the following batch file instead.  You MAY have to specify the full path to cleanmgr.exe, and will probably need the "start" command in front of it.

@echo off
start cleanmgr /sagerun:7

IF, for some reason there are Temp files that are better deleted before Windows starts up, you can use a batch file to append a line to autoexec.bat specifying a cleanup batch file to be run and then force the system to reboot so that the cleanup batch file is run before windows starts.   Let's call the file that will do the cleanup at reboot "RebCln.bat".  I'll leave the writing of RebCln.bat up to you, but here's roughly what the other batch file would look like that is called by the scheduler and which then writes the line to autoexec.bat, and forces a reboot:

@echo off
:: make a clean copy of autoexec to restore later
if not exist c:\autoexec.xxx copy c:\autoexec.bat c:\autoexec.xxx
echo call c:\batch\rebcln.bat >> autoexec.bat
c:\windows\rundll32.exe shell32,SHExitWindowsEx 2SHExitWindowsEx 2

The only thing that you would have to add at the very end of your "RebCln.bat" file is a line that restores the backed up autoexec.xxx as autoexec.bat again (ie. the original file without the cleanup line in it):

if exist c:\autoexec.xxx del c:\autoexec.bat
copy c:\autoexec.xxx > c:\autoexec.bat
OR
type c:\autoexec.xxx > c:\autoexec.bat

Now, I provided a link earlier for a batch file named "Today.bat", which For-Soft did not think would work:

http://www.ericphelps.com/batch/samples/today.bat.txt

I have tested it on my Windows 98 computer, and it works perfectly.  First of all, for this demonstration, create some files in a new folder eg. C:\BATCH:

TODAY.INI

25/06/2004=history.bat
31/07/2005=present.bat
12/09/2006=future.bat

PRESENT.BAT

@echo off
echo.
echo             Today is the 31st July 2005
echo             present.bat was called from today.ini
echo.
echo             press any key to finish
pause>nul
exit

HISTORY.BAT

@echo off
echo.
echo             Today is the 25th June 2004
echo             (actually, I changed the system date)
echo.
echo             history.bat was called from today.ini
echo.
echo             press any key to finish
pause>nul
exit

FUTURE.BAT

@echo off
echo.
echo             Today is the 12th September 2006
echo             (actually, I changed the system date)
echo.
echo             future.bat was called from today.ini
echo.
echo             press any key to finish
pause>nul
exit

Lastly, create TODAY.BAT, which is the batch file that will act as your calendar/scheduler:

@echo off
:CHECK1
::
:: Check for presence of source file
::
if not exist today.ini goto :MAKEINI
::
:: View and change INI file for testing
:: only.  Remove this command in real file.
::
edit today.ini
::
:: Now modify the system date to whichever
:: line in 'Today.ini' you wish to be run.
:: This is only for testing purposes.
:: Remove the following command in the real file.
::
DATE
::
:: Put date into DATE variable
::
@echo.|date|find /i "current">#urrent.bat
@echo set date=%%4>current.bat
call #urrent.bat
del ?urrent.bat
::
:: Put command for today into TODAYSCOMMAND variable
::
find "%date%=" today.ini | sort /r | date | find "=" > en#er.bat
@echo set todayscommand=%%5> enter.bat
call en#er.bat
del en?er.bat > nul
::
:: Cleanup - DATE variable and INI entry
::
type today.ini|find /v "%date%">today.ini
set date=
::
:: The following command is just for demonstration
:: purposes to show you that the correct line was
:: wiped from 'Today.ini'.  Remove this section
:: from the real batch file.
::
echo.
echo Today.ini - after line for current date stripped
echo =========
echo.
type today.ini
echo.
echo end of 'Today.ini' press any key to continue ...
pause>nul
::
:: Run today's command and then empty variable
::
call %todayscommand%
set todayscommand=
goto :END
::
:: You will only get here if 'Today.ini'
:: is not in same folder as Today.bat
::
:MAKEINI
echo ??/??/??= > Today.ini
goto :CHECK1
:END
exit

When you run this demonstration, it will open TODAY.INI so you can take note of the dates.  Close the DOS Edit window (File > Exit) and it will then run the DATE command.  To maintain the current date (31 July 2005 in this demo), just press the ENTER key.  To change the date to any other date, just enter it in the format  dd-mm-yy and press Enter.

Once done, it will look at the dates in the INI file and compare them against the current system date.  If a match is found for any of the lines in the INI file, then the corresponding command on that line will be run.  That line is then stripped out of the INI file so that it won't be run again if the batch file is run again that day.

You obviously replace the program to be run on the specific dates with the cleanup batch file, or you could use the cleanmgr /sagerun:x example if being run as Windows loads (ie. from a shortcut in the Start Menu).  If being run from a line in autoexec.bat, keep the batch file names short.

Hopefully this explains things in greater detail.

 

by: BillDLPosted on 2005-07-30 at 12:31:13ID: 14562571

You'll enjoy reading hat one, corel47 :-)

 

by: BillDLPosted on 2005-07-30 at 12:38:56ID: 14562587

Incidentally, you can use the file RESTART.COM from the EBD.CAB file on a Windows 98 boot floppy (or get it from BASE4.CAB on the Win98 CD using WinZip or DOS Extract) to restart the computer.  Usually it only works when run from DOS to reboot a computer, but you can test it.

 

by: coral47Posted on 2005-07-30 at 20:40:45ID: 14563570

>> You'll enjoy reading that one, corel47 :-) <<  Oh yeah. Takes me back a few years. I never wrote one to check for the date, though.    : D

 

by: BillDLPosted on 2005-07-31 at 01:45:34ID: 14564100

One suggested improvement for that DEMO batch file (Today.bat) where it opens DOS Edit to allow you to add a scheduled task.  It's right at the tail-end of the batch file.

:MAKEINI
echo ??/??/????=path and program name to run > Today.ini
goto :CHECK1
:END
exit

It is worthy of note that the original batch file written by Eric Phelps (http://www.ericphelps.com/batch/samples/today.bat.txt) shows that you should create scheduled tasks in the INI file using the date format mm-dd-yy as it appears on screen if you type the DOS "DATE" command.  Whatever operating system Eric was using showed the following when the DATE command was called:

Current date is Sun 10-12-1997
Enter new date (mm-dd-yy):

I have modified the batch file above to reflect the way MY windows 98se system shows the dates.  If I type the DATE command, it shows the following:

Current date is Sun 31/07/2005
Enter new date (dd-mm-yy):

You need to test first to ensure that the format specified in the Today.INI file matches the format that will be generated by the batch file when it uses the DATE command output.  My INI file has to specify the date format  dd/mm/yyyy  because that is what the system generates.

I thought I would just square that up before I am told that it doesn't work.  It DOES.

Bill

 

by: suzeshPosted on 2005-08-09 at 04:11:34ID: 14631479

I am in puzzle how to create the batch file. Dear BillDL??

 

by: For-SoftPosted on 2005-08-09 at 06:18:26ID: 14632208

Batch file is a text file with .BAT file extension.

 

by: BillDLPosted on 2005-08-09 at 08:07:12ID: 14633308

Let me re-cap on your requirements:

1. You are the administrator of a technical institute
2. Computing students pass through there every three months
3. You would like to schedule a process to run after every 3-month session
4. The process should get rid of all unnecessary files created during that session so that all ther computers are cleaned out and ready for the next batch of students
5. This process should be able to run automatically in your absence.

We have covered some methods where you can easily schedule this process to run at a specific time, day, and date.  I am referring to the "schedule.exe" program I spoke about above, where you add separate lines to the program's .INI file.

Say, for instance, that your batch file to do this cleanup operation will be named "CLEANUP.BAT" and will be in the same folder (C:\BATCH) as schedule.exe.  Say you have one of those 3-monthly sessions ending on Friday 12th August 2005, and your new students will enrol on Monday 15th August 2005.  So you would want the cleanup operation to run at 09:30 on the Monday just after the new students had all powered up their computers and were listening to the Tutor making the introductions.

Ignoring holidays, the next cleanup operations should then be on the following dates to coincide with a new intake of students : Monday 14 November 2005, Monday 13 February 2006, Monday 8 May 2006, and so on.

OK, so your SCHEDULE.INI file would look like this:

14/11/2005=cleanup.bat
13/02/2006=cleanup.bat
08/05/2006=cleanup.bat

Now, that brings us to your CLEANUP.BAT file.  It all depends on just what you need to delete.  One complication is that, when new students arrive, I presume that they have to set up separate "User Profiles" so that they have to log into Windows 98, and can have their own Desktop layout, their own colour schemes, different Windows Explorer "view" preferences, etc.  This would complicate things, because you would have no way of knowing each user name 9 or 12 months ahead.  As you will be aware, a Windows 98 "user profile" stores settings for different users of the one computer as:

C:\Windows\Profiles\<username>\-->

where folders like Desktop, Start Menu, Temporary Internet Files, Cookies, History, Recent, etc are all gathered together for each user under their <username> folder.

If all your students are all allocated a SEPARATE computer and DON'T have separate "user profiles", then that makes things a lot easier.  You will find some example cleanup batch files here:

http://www.langa.com/cleanup_bat.htm

Fred Langa is well known, and I have tested a few of these batch files with good success, but batch files like this can damage a computer just as easily as they might successfully delete things, so TEST them on one computer first.  Some of these .BAT files MUST ONLY be run from DOS and not from within Windows, or they won't work.

from one of the Experts-Exchange experts:

http://home.ntelos.net/~write/purgeall.txt

I'm afraid that actually writing a batch file for YOUR particular situation is a bit beyond the scope of your question which really asked about "how to schedule" a batch file.

Just so that you understand a few concepts used in some of these batch files you will find:

"IF EXIST"  folder/file  then do something.

You can test for the existence of a folder (evern an empty one) using a command like the following, which would then change directory into the "profiles" folder:

if exist c:\windows\profiles\nul cd c:\windows\profiles

If you just issued the command   cd c:\windows\profiles   and that folder didn't exist, then it would stop and tell you this, which you don't want.

If you need to check for the existence of files in a certain folder and eg. delete all .txt files from that folder, then you can use the "if exist" test to establish if any exist.  For example, if you just issued this command:
del c:\windows\temp\*.txt
but there weren't any .txt files in there, then it would give an error telling you this.  Instead, if you issued this command, it would only delete .txt files IF they existed:
if exist c:\windows\temp\*.txt del c:\windows\temp\*.txt

By adding >nul  after a command to delete, copy, or other action, it won't show confirmation like eg. 10 file(s) deleted:
if exist c:\windows\temp\*.* del c:\windows\temp\*.*>nul

You can also use the NOT expression in an "if exist" test, eg.
if not exist c:\junk\*.* echo Folder is empty

You can't just delete a folder using the DEL command if it has files or sub-folders in it.  The DELTREE command is dangerous, but can be used to wipe out an entire folder and ALL its content.  Let's say that a user created a folder named "Stuff" in the c:\my documents folder and it was full of files and sub-folders also with files.  You could delete the "Stuff" folder completely using:
DELTREE c:\mydocu~1\stuff
This would prompt you to delete its sub-folders unless you added /Y (which is what makes it dangerous):
DELTREE /Y  c:\mydocu~1\stuff

Certain files or folders might only allow themselves to be seen, accessed, or deleted/copie/moved IF you first remove the attributes that normally prevent this.  You can SEE a file or folder's attributes by issuing the  ATTRIB command eg.
ATTRIB  c:\mydocu~1\stuff
ATTRIB  c:\mydocu~1\stuff\*.*

Attributes are:
A = Archived
R = Read-Only (will prevent copying, moving, renaming, and deletion)
S = System
H = Hidden (will tell you "file not found" and resists copying, moving, renaming, and deletion).

To REMOVE an attribute, just type a minus before the attribute, and to add the attribute, add a plus.  Example, the file c:\mydocu~\stuff\photos\thumbs.db is preventing deletion of the folder "stuff" because it is a hidden and read-only file:

attrib -a -h -r c:\mydocu~1\stuff\photos\thumbs.db
del c:\mydocu~1\stuff\photos\thumbs.db>nul
deltree /Y c:\mydocu~\stuff

There are some super-hidden files in many of the system folders and user shell folders that can prevent you from deleting content from eg. C:\windows\temporary internet files folder and you usually have to remove their attributes first.  Files like index.dat, desktop.ini, and folder.htt are examples of files that are usually +h +r +s.

DOS commands don't like spaces in file or folder names, and think that the space signals the end of the file name, so folders like:
c:\windows\temporary internet files
c:\windows\profiles\bill\start menu
either have to be enclosed in " "
eg. cd "c:\windows\temporary internet files"
OR abbreviated to their DOS Names
eg. cd c:\windows\tempor~1

Folder names like c:\windows\temporary internet files\content.ie5 can confuse things because the  Content.IE5  looks like a file named "content" with the .IE5 file extension.

The best way to see the dos names for files and folders is by either right-clicking on it and looking at the MS-DOS Name under the properties, or by running a DIR command on a folder without any switches, eg: to get a list of ONLY folder names in the "Windows" directory:

DIR /on /ad /p c:\windows

APPLIC~1 = Application Data
DOWNLO~1 = Downloaded Program Files
FAVORI~1= Favorites
STARTM~1= Start Menu
TEMPOR~1 = Temporary Internet Files
etc.

If I were you, I wouldn't be messing arount trying to delete all trash content created by curious students during a 3 month period, because there will be a LOT of junk like files with no extensions saved all over the place.

Have you considered doing this:

1. Fresh installation of Windows 98 configured to suit all users.
2. Make a backup with Microsoft Backup to include everything that it is able to back up.  3. Save it as a file with the .QIC extension to a partition or a folder that won't be accessed.
4. Run the "system recovery" from the Windows CD to restore the system to that state.

Have a look on a Win98 CD in the folder \tools\sysrec and read the document "recover.txt".  This explains that the batch file "pcrestor.bat" will do the following:

1. Run setup.exe from the win98 CD and install Windows from the instructions contained in the file "msbatch.inf"
It runs setup with the following options to make it faster and cleaner:
setup.exe c:\restore\msbatch.inf /is /id /iq /im /id /ie /IW, and the instructions in the MSBATCH.INF file make the reinstallation almost completely automated.
2. When it reboots, it will then restore the backup made, so you have a system just about ready to be used by a new user..

You can create your own custom MSBATCH.INF file by installing "MSBATCH" from the folder \tools\reskit\batch, and then use the "gather now" button to get the current settings from a computer with a freshly configured installation of Windows 98.

A better option would be to format the drive each time and then run the system recovery for a totally clean system for each new intake of students.

Hope this helps.

 

by: BillDLPosted on 2005-09-21 at 19:49:35ID: 14933811

Thank you, LeeTutor and PAQ_Man.

Isn't it really rewarding and satisfying to have gone to great lengths to provide in-depth explanations to try and help someone out, and then to receive no feedback !!  :-(

What a wonderful way to accrue points, it's just the waiting for them that is frustrating.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...