Jump to content

Can't get files to delete


Recommended Posts

Hello,

Below is a my first Autoit script. There are a few areas that will not work. I have marked these commands in the script. The problem is with the FileDelete commands. The files will not delete. I understand that if they are in use that they wouldn't be able to be deleted. However, if I open a DOS prompt and delete the files, they delete fine. Same through Windows Explorer. To delete the files in the C:\Temp directory, I had to resort to deleting the entire folder and then re-creating it. Can anyone help me with these?

Thanks.

; ----------------------------------------------------------------------------

;

; AutoIt Version: 3.0

; Language: English

; Platform: Win9x/2000/XP

; Function: Clean Local Drives of Uneeded Files

; Script ver: 0.03

; Date: August 14, 2005

; Author: David R. Desclos

;

; ----------------------------------------------------------------------------

; Set the RunAs parameters to use Domain Administrator Account

RunAsSet ("username", "domain", "password")

; Flag Internet Cache Files for Deletion

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files","", "REG_SZ","{9B0EFD60-F7B0-11D0-BAEF-00C04FC308C9}")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files","Display", "REG_SZ", "Temporary Internet Files")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files","Description", "REG_SZ", "The Temporary Internet Files folder contains Web pages stored on your hard disk for quick viewing. Your personalized settings for Web pages will be left intact.")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files","AdvancedButtonText", "REG_SZ", "&View Files")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files","Priority", "REG_DWORD", "00000064")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files","StateFlags0999", "REG_DWORD", "00000002")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files","StateFlags", "REG_DWORD", "00000002")

; Flag Temporary Offline Files for Deletion

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Offline Files","", "REG_SZ", "{750fdf0f-2a26-11d1-a3ea-080036587f03}")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Offline Files", "Priority", "REG_DWORD", "000000c9")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Offline Files", "StateFlags0999", "REG_DWORD", "00000002")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Offline Files", "StateFlags", "REG_DWORD", "00000002")

; Flag Downloaded System Files for Deletion

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files", "", "{8369AB20-56C9-11D0-94E8-00AA0059CE02}")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files", "Display", "REG_SZ", "Downloaded Program Files")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files", "Description", "REG_SZ", "Downloaded Program Files are ActiveX controls and Java applets downloaded automatically from the Internet when you view certain pages. They are temporarily stored in the Downloaded Program Files folder on your hard disk.")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files", "Priority", "REG_BINARY", "64000000")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files", "AdvancedButtonText", "REG_SZ", "&View Files")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files", "StateFlags0999", "REG_DWORD", "00000002")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files", "StateFlags", "REG_DWORD", "00000002")

; Delete Files Using Windows Disk Cleaner Based on Profile #999 Set Using Reg Entries Above

RunWait("cleanmgr /sagerun:999")

; Delete Files in C:\Temp Directory (Doesn't Work Properly)

FileDelete("C:\Temp\*.*")

; Delete Files in C:\Temp Directory

DirRemove("C:\Temp", 1)

; Delete Old Setup Logs (Doesn't Work Properly)

FileDelete(@WindowsDir & "\*.log")

FileDelete(@WindowsDir & "\*.txt")

FileDelete(@WindowsDir & "\*.bak")

FileDelete(@WindowsDir & "\*.old")

FileDelete(@WindowsDir & "\*.tmp")

; Delete Old Help Desk Scripts & Directory

DirRemove("c:\Help_Desk", 1)

DirRemove("c:\Help Desk", 1)

; Delete Files in User Profile Temp Folder (Doesn't Work Properly)

FileSetAttrib(@UserProfileDir & "\Local Settings\Temp\*.*", "-RASHNOT", 1)

FileDelete(@UserProfileDir & "\Local Settings\Temp\*.*")

; Delete Temporary Active Setup Files

FileDelete(@WindowsDir & "\msdownld.tmp\*.tmp")

; Delete Windows Debug Memory Dump Files (Doesn't WOrk Properly)

FileDelete(@WindowsDir & "\*.dmp")

; Empty Recycle Bin

FileRecycleEmpty("C:\")

FileRecycleEmpty("D:\")

; Add C:\Temp Directory

DirCreate("C:\Temp")

; Reset User's Permissions

RunAsSet ()

exit

Link to comment
Share on other sites

RunAsSet() has only an effect on Run() and RunWait(), so the command FileDelete(@WindowsDir & "\*.dmp") will fail if the user who started the script has no permisson to delete the file. Search the forum for RunAsSet for a solution to your problem. What you need is a script that restarts itself with admin privileges. Search for "+RunAsSet +restart".

EDIT: Or check out this: http://www.autoitscript.com/forum/index.ph...topic=14710&hl=

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

maybe you should take a look at this

Here is a small part of my cleaner

http://xpcleanmenu.hostrocket.com/image/Auto-screen.jpg

You went for cleaning...and alot of use of the registry??

I went for (safety) restore point, adware, spyware, cleaning temps, cleaning registry, and then defrag... later it had a disappearing top menu bar... and now it has top menu bar "skins"...

http://www.autoitscript.com/forum/index.ph...l=xpclean+menu#

Well it was fun... yours has great ideas too!

8)

PS the actual web site is below

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...