Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically delete files in Temp ? 2

Status
Not open for further replies.

mirceapop14

Programmer
Apr 1, 2004
69
RO
How can be automatically deleted all files from Temp folder in a user profile when the user Log off ? Some example for scripting Log off, please ...
Thanks a lot.
 
No , the solution is very good if it is placed at startup.
Wait for advice.
Thanks.
 
1. Make file xp.cmd (use notepad etc.) and write into it:

@echo off
cd %homedrive%%homepath%
rd /s/q locals~1\tempor~1 (this is for erasing the TemporaryInternetFiles folder)
rd /s/q locals~1\temp (this is for erasing the Temp folder)
md locals~1\temp (this is for creating the Temp folder)
md locals~1\tempor~1 (this is for creating the TemporaryInternetFiles folder)

2. Store the xp.cmd file in your startup folder.

3. Reboot your computer.
 
If you want to do it on restart or shutdown, you can seve it on your desktop and you also type at the end the following :

%windir%\system32\shutdown.exe

This links to the shutdown application. There are, of course, many suffixes which be added to generate the desired result.
-f -s -t 10 -c "GoodBye" causes the program to force shutdown the system after 10 seconds with the message 'GoodBye'.
by replacing the -s with a -r this restarts your system. Replacing it with -l logoff the user instantly.

If you run it like this then to abort the shutdown or the restart type on Start->Run this:

shutdown /a

Good Luck
 
Thanks!!! I give some stars !

So, if i placed that .cmd in startup folder it will be executed when computer restart and a specified will logon on that workstation. If the user will log off and another user will log on, this will not work , am i right ?

The correct solution ( probably wrong ) is to add

%windir%\system32\shutdown.exe -f -l

to the end of yours .cmd file and place a shortcut on the desktop for every user ? ( not so easy to done )

As an extension, can i delete those temporary files for all users who ever log on at that workstation ?
But if some anitivirus will not pwermit to remove those folders ?

Thanks anyway ! I have a start point !


 

I assumed that you have windows XP

If you have some other OS tell me, cause i dont thing that those things will work.

Tell me the OS you use and i 'll tell solutions for the things you just asked.
 
Both Group Policy and Scheduled Tasks support these four events for scripting:

. at Startup
. at Logon (A)
. at Shutdown
. at Logoff (B)

In addition, each user has a folder in their profiles in which startup applications and scripts can be specified: C:\Documents and Settings\user\Start Menu\Programs\Startup (C)

If you use (A), (B) or (C) for you cleanup script, you need not concern yourself with the shutdown.exe command at all.


 

Very nice bcastner indeed

mirceapop14, he deserves a star too.

You can place the file you'll make with the 'remove dir' commands, (without 'shutdown') into wherever you want.
(beter is in
C:\WINDOWS\System32\GroupPolicy\Machine\Scripts\Startup)

then
srat->run->gpedit.msc

Computer Configuration->Windows Settings->Scripts(Restart/Shutdown)
or
User Configuration->Windows Settings->Scripts(Logon/Logoff)

right click on the two choises on your right, hit properties
and click 'Add' to add the file you made.

Good luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top