kixscript to delete temp files in temp directory

I am looking for a kixscript that will delete all files and directories in the c:\documents and settings\username\local settings\temp.
johnbowdenAsked:
Who is Participating?
 
craylordCommented:
$mylocal=ReadValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Local Settings")
$cmd1="attrib.exe" + " " + " -r -s -h " + '"$mylocal\temp\*"' + " /s /d"
$cmd2="del.exe" + " " + '"$mylocal\temp\*"' + " /s /q"
Shell "%COMSPEC% /c " + $cmd1
shell "%COMSPEC% /c " + $cmd2
0
 
innovator_joelCommented:
Greetings johnbowden!

I don't have the information you have asked, but you can refer the link:

http://prope.insa-lyon.fr/~ppollet/netware/dclean/index.ssi

This is a good utility.
0
 
kfullartonCommented:
If you already have a kix script in place, add the following line:

DEL c:\documents and settings\username\local settings\temp\*.*

If not, copy the above line to note pad and save it as script.kix to your NETLOGON share on a domain controller.  Open Notepad, type:

@echo off
kix32.exe script.kix
exit

You must also make sure that you have the kix32.exe in the NETLOGON share as well.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
JamesHarrisonCommented:
I use the following in mine:

? "Deleting temporary files"
If EXIST( "c:\winnt\temp" )
      SHELL ("%COMSPEC% /C DEL C:\winnt\temp\*.* /s /q 1> nul 2>&1")
      ELSE
      MD "c:\winnt\temp"
ENDIF

;CLEAN UP THE TEMP DIRECTORY
If EXIST( "c:\temp" )
      SHELL ("%COMSPEC% /C DEL C:\temp\*.* /s /q 1> nul 2>&1")
      ELSE
      MD "c:\temp"
ENDIF

Just change the above to reflect your path and maybe use the %username% variable.

Let me know if you need more info

J
0
 
craylordCommented:
$mylocal=ReadValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Local Settings")
$cmd="del.exe" + " " + '"$mylocal\temp\*"' + " " + " /q"
Shell "%COMSPEC% /c " + $cmd
0
 
craylordCommented:
Those three lines will get the local app folder, set the del line to use that regfile appended with "temp" (/q, dunno if you have to use /y to suppress) and the execute command. I'll leave it up to you for you if endif's. If you need help with that please ask. I use kixtart pretty extensively.
0
 
johnbowdenAuthor Commented:
Thanks a bunch for all the responses. I will be implementing these this weekend.
0
 
JamesHarrisonCommented:
Good luck!  let us know how you get on!
0
 
johnbowdenAuthor Commented:
Hi Craylord, yes, that worked great. One thing though, I would like it to delete all files and directories below. Is that possible to do with some additions to this script


Thanks again
0
 
craylordCommented:
add /s to this line

$cmd="del.exe" + " " + '"$mylocal\temp\*"' + " " + " /s /q"

This is where to add variables concerning the del command. " /s /q"
0
 
johnbowdenAuthor Commented:
Ok, we're almost there. I have a few directories in the temp directory that are set to read only. I've run the attrib -r -h -s * /s /d but it still won't change their status. I may have to manually delete them if I run across them in the future.
0
 
craylordCommented:
There is an /a to delete files based on attributes. r = read only, s = system files, h = hidden, a = files ready for archiving.
0
 
johnbowdenAuthor Commented:
I don't get the /a option when I run that attrib command. How is the format for that. So far I have the following

$mylocal=ReadValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Local Settings")
$cmd1="attrib.exe" + " " "/-r -s -h" + '"$mylocal\temp\*.*"' + " " + "/s /d"
$cmd2="del.exe" + " " + '"$mylocal\temp\*"' + " " + " /s/q"
Shell "%COMSPEC% /c " + $cmd1
shell "%COMSPEC% /c " + $cmd2
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.