473,888 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting folder "Temporary Internet Files"

Hi,
I'm trying to clear the TIF on Windows XP programmaticall y with the
below code.
This code works fine on any folder but the TIF. For some reason the
atEnd() statements always defaults to true and no files are deleted in
the folder.
The peculiarity of this issue is that the files/subfolders cannot be
seen through the windows explorer either. I can only access/delete
them through a command shell.
Any ideas?
Many thanks
Rosa
CODE:
############### ############### ############### ############### ############### ##
// This is the root, which we analyse
var sRoot="C:\\Docu ments and Settings";
var sLocalSettings= "\\Local Settings\\"

// Declaration of other variables
var fso, f, fc, fcf, logfile,TIFFold er, s;
s= "";

// Create the FileSystemObjec t
fso = new ActiveXObject(" Scripting.FileS ystemObject");

// Navigate to our root
f = fso.GetFolder(s Root);

// Log-file
logfile = fso.CreateTextF ile("c:\\del.lo g", 1);
logfile.WriteLi ne("Logging for the script to delete Temporary Internet
Files Folder");
logfile.WriteLi ne("=========== =============== =============== =============== ========");

// Enumerate all Subfolders to fc, by using the SubFolders-method of
FSO
fc = new Enumerator(f.Su bFolders);
for (; !fc.atEnd(); fc.moveNext())
{
// store path to the Temporary Internet Files in TIFFolder
TIFFolder = fc.item() + sLocalSettings + "Temporary Internet
Files";

// dont even try to delete in the following Profiles
if ( (fc.item() == (sRoot + "\\All Users")) ||
(fc.item() == (sRoot + "\\Default User")) ||
(fc.item() == (sRoot + "\\LocalService ")) ||
(fc.item() == (sRoot + "\\NetworkServi ce")))
{
continue;
}
// Check, if there is a folder Temporary IE Files
if (fso.FolderExis ts(TIFFolder))
{

// Now we can delete that folder
try
{
fso.DeleteFolde r(TIFFolder);
logfile.WriteLi ne("FOLDER: " + TIFFolder + " has been deleted
successfully");
}
catch(e)
{
logfile.WriteLi ne("FOLDER: " + TIFFolder + " Could not be deleted.
--- Error: " +e.number+ " Error-description: " + e.description);
fcf = new Enumerator(f.fi les);
if (fcf.atEnd())//for TIF this is always true
{
logfile.WriteLi ne("No files in folder.");
}
else
{
for (; !fcf.atEnd(); fcf.moveNext())
{
s = fcf.item();
try
{
s.Delete();
logfile.WriteLi ne("FILE: " + s + " has been deleted
successfully");
}
catch(e)
{
logfile.WriteLi ne("FILE: " + s + " Could not be deleted. ---
Error: " +e.number+ " Error-description: " + e.description);
}
}
} }
}
}
############### ############### ############### ############### ############### ###
Jul 23 '05 #1
5 16844
In article <39************ **************@ posting.google. com>,
Ro**********@ho tmail.com enlightened us with...
the folder.
The peculiarity of this issue is that the files/subfolders cannot be
seen through the windows explorer either.


Probably because they're hidden.

Open Windows Explorer. (just open my documents or something)
Click on Tools -> Folder Options
Click on the View tab.
Where it says "Hidden files and folders", choose the option that says "Show
hidden files and folders".

--
--
~kaeli~
She was engaged to a boyfriend with a wooden leg but broke
it off.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
"Rosa" <Ro**********@h otmail.com> wrote in message
news:39******** *************** ***@posting.goo gle.com...
Hi,
I'm trying to clear the TIF on Windows XP programmaticall y with the
below code.
This code works fine on any folder but the TIF. For some reason the
atEnd() statements always defaults to true and no files are deleted in
the folder.
The peculiarity of this issue is that the files/subfolders cannot be
seen through the windows explorer either. I can only access/delete
them through a command shell.
Any ideas?
Many thanks
Rosa


To bring this on topic, I've converted the script to JScript. I've also
removed the logging, but it should be easy enough to add back in (just
look for where I WScript.Echo() each file I'm deleting).

var TEMPORARY_INTER NET_FILES = 0x20;
var COOKIES = 0x21;

var shell = new ActiveXObject(' Shell.Applicati on');

var folder = shell.Namespace (TEMPORARY_INTE RNET_FILES);
// or
//var folder = shell.Namespace (COOKIES);

// have to take the -self- property of the namespace to get the actual
object
folder = folder.self;

var path = folder.Path + '\\';
WScript.Echo(pa th);

var fso = new ActiveXObject(' Scripting.FileS ystemObject');

var stack = [];
stack.push(fso. GetFolder(path) );

while (stack.length > 0)
{
var folder = stack.pop();
for (var en = new Enumerator(fold er.Subfolders); !en.atEnd();
en.moveNext())
{
try
{
stack.push(en.i tem());
}
catch(e)
{
}
}
for (en = new Enumerator(fold er.Files); !en.atEnd(); en.moveNext())
{
try
{
// WScript.Echo(en .item().Path);
fso.DeleteFile( en.item().Path) ;
}
catch(e)
{
}
}
}

Note a couple of things:

1) My version doesn't depend on any "magic" folder names, where ever the
Temporary Internet Files directory resides (for the current user) is
where my script will retrieve it from (so you could set this as a logout
script and it would clear the current user's cache when they log out of
Windows). If you are going to modify it back to do all users, I'd
suggest you try to figure out a more sensible way of determining the
current profile directory, such as reading
HKEY_LOCAL_MACH INE\SOFTWARE\Mi crosoft\Windows
NT\CurrentVersi on\ProfileList\ ProfilesDirecto ry from the Registry.

2) Notice that I've wrapped the file manipulation code in try-catches.
In this script if there is a problem reading a file -- like, I don't own
it and therefore I get a security violation -- I want to skip the
problem and continue on. I didn't want to write robust error handling
for a script I was giving away for free and I don't use myself.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #3
Hi Grant,

Thanks for the adaptation. This doesn't however solve the problem
yet...
In regards to Kaeli, the settings are set so that I can see hidden
files and folders. There is just some peculiarity with this particular
folder.

Thanks
Rosa
Jul 23 '05 #4
In article <39************ **************@ posting.google. com>,
Ro**********@ho tmail.com enlightened us with...
Hi Grant,

Thanks for the adaptation. This doesn't however solve the problem
yet...
In regards to Kaeli, the settings are set so that I can see hidden
files and folders. There is just some peculiarity with this particular
folder.


I found this in Google Groups. I think it's relevant here. Looks like you're
not supposed to be able to delete that stuff (TIF) programmaticall y?

=============== =============== =============== ============
Message-ID: <OGRVBovlBHA.15 52@tkmsftngp02>

As for Temporary Internet Files (TIFs), there is only one proper
method for normally deleting these files. Internet Setting | General Tab |
Delete Temporary Internet Files button. If prompted to delete Offline
Content, do so, especially if you use Outlook Express 5.5 or above. (There's
a bug, that's why.) Simply deleting TIFs using Windows Explorer (or
"Cleanup" programs, for that matter) will not properly update the index.dat
file for that folder. This can lead to problems. You *can* completely delete
the folder, files, index.dat and all, but only in a "pure" DOS setting, and
it's only necessary if there are problems suspected. For more in-depth
descriptions of TIFs, Cookies, and History, go to http://groups.google.com,
use Advanced Search, and look for messages with "Gary Terhune" as Author
(without the quotation marks, though), and "Smoke and Mirrors" in the content
section (this time *with* the quotation marks to indicate an exact phrase.)
=============== =============== =============== ============

--
--
~kaeli~
Black holes were created when God divided by 0.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #5
Hello Kaeli,

Thanks for your posting, it was very helpful!

Cheers
Rosa
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2207
by: Konrad L. M. Rudolph | last post by:
I hope this is the right NG, please notify me if not. I have got a problem with the "recent files" list of the start page in VS.NET: yesterday I created a new projekt which has the same name as an already existing project stored at another location. Unfortunately, VS.NET doesn't seem to support double names in the "recent files" list: only /one/ entry with the double name is listed and even more unfortunate, it is the one which I don't...
3
6137
by: Jim | last post by:
Is it possible to read the Temporary Internet Files folder using C#? I'm messing with FileIO (newbie here) and everything seems to work fine until I try to read the list of files in this Temporary Internet Files folder. I'm only received 1 file when I know there is more. Any suggestions are very appreciated. Thanks
2
9100
by: John Saunders | last post by:
I deploy web applications in what may be an odd manner. For every web site "x", I have an "x2" web site which points to an empty directory. I can then use Copy Project in VS.NET to deploy to the empty directory, and have the x2 site QA'd. I then switch over by creating a new empty directory for the next time, and in IIS, pointing the x2 site to the new directory and finally pointing the "x" site to the newly-deployed directory. This...
4
2352
by: Nicolás Castagnet | last post by:
Hi, I write this post because I notice a strange behavior related with "Temporary Internet Files" and maybe some of you can help me to understand it. I am working in a web application with ASP.NET. Recently, I group of user have problems with it because the values of the sessions were not stored correctly (the application save the username in a login page, then other page try to get it and the result was always ""). We restart the web...
1
2171
by: Boris | last post by:
We have some .NET 1.1 DLLs which we want to use in a ASP.NET 1.1 web page (actually one is a real .NET DLL in Managed C++ while the others are native Windows DLLs). First we copied all of the DLLs to /bin. However when we do this we get a configuration error. When we copy the DLLs to "/Temporary ASP.NET Files/..." everything works. Does anyone know what could be the reason that the DLLs can be loaded from the temporary files but not from...
1
1847
by: SalamElias | last post by:
I have a VS 2003 VB web project which works fine, in IE, debug....After several browsing in IE or debugging several ti;mes I start to get the ugly error "Configuration Error ", Access is denied: 'mydll', and the following line in red color in the ouput "Line 200: <add assembly="*" />" Source File: c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config Line: 200 Assembly Load Trace: The following information can be...
4
29220
by: pedestrian via DotNetMonster.com | last post by:
I'm using VB 2005. How to get the full path for "Program Files" folder in Windows, ie. either it is C:\Program Files or D:\Program Files or etc.? How about the full path of "Windows" folder? (either C:\Windows or C:\WINNT etc.) Thanks for replying... --
2
2056
by: Ralf Kaiser | last post by:
Hi, is it possible to define another place where the "Temporary ASP.NET Files" are stored? I do not want to have them on my system partition because i have a separate partition for all the temporary stuff on a separate physical drive. Is there a registry entry that defines the place for that folder?
3
4769
by: =?Utf-8?B?S2Fyc3RlbiBMdW5kc2dhYXJk?= | last post by:
Hi, I have made an application in C#, where I use the statement Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) to get the name of the "Program Files" folder. It works fine in "Windows 2000" and "Windows XP", but it fails when I'm using "Windows Vista Ultima" in Danish. It returns "Program Files" instead of "Programmer". "Programmer " is the name of the folder in explore. Hope someone can help me - Thanks
0
9800
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11185
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7990
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4247
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.