![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Vista Ultimate SP1 x64 | Script to delete files on shutdown I want to have windows to automatically delete all files in my temp folder on shutdown except one. I know how to use gpedit to run scripts on shutdown. I need someone make the script for me to remove said files if its possible? btw i moved my temp folder to 'C:\temporary Files' & the one file i dont want it to delete is 'C:\temporary Files\Darren.bmp' |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Script to delete files on shutdown "fieseler" <guest@xxxxxx-email.com> wrote in message news:fcf970a6200385c5dab6b112c63e66a1@xxxxxx-gateway.com... Quote: > > I want to have windows to automatically delete all files in my temp > folder on shutdown except one. I know how to use gpedit to run scripts > on shutdown. I need someone make the script for me to remove said files > if its possible? > > btw i moved my temp folder to 'C:\temporary Files' & the one file i > dont want it to delete is 'C:\temporary Files\Darren.bmp' > shutdown batch file: @echo off for /F "delims=" %%a in ('dir /b /a-d "c:\Temporary Files" ^| find /i /v "Darren.bmp"') do echo del "%%a Remove the word "echo" in Line 2 to activate the batch file. BTW - I don't think it's a good idea to keep files in the temp directory if you want to keep them. Without this restriction the command would be much simpler: @echo off del /q "c:\Temporary Files" |
My System Specs![]() |
| | #3 (permalink) |
| Vista Ultimate SP1 x64 | Re: Script to delete files on shutdown I got the this one to work @echo off del /q "c:\Temporary Files" but the other one below wont delete files at all for some reason. I did remember to remove the echo in the last line also. @echo off for /F "delims=" %%a in ('dir /b /a-d "c:\Temporary Files" ^| find /i /v "Darren.bmp"') do del "%%a Plus is there any way to get it to delete folders as well? I have a few folders in there often left by one of my sidebar gadgets. I want these to be deleted also because the gadget just creates new ones every time it runs anyway. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Script to delete files on shutdown "fieseler" <guest@xxxxxx-email.com> wrote in message news:276f42455ef2b6f05cf64737d3ae27b7@xxxxxx-gateway.com... Quote: > > I got the this one to work > > @echo off > del /q "c:\Temporary Files" > > but the other one below wont delete files at all for some reason. I did > remember to remove the echo in the last line also. > > @echo off > for /F "delims=" %%a in ('dir /b /a-d "c:\Temporary Files" ^| find /i > /v > "Darren.bmp"') do del "%%a > > Plus is there any way to get it to delete folders as well? I have a few > folders in there often left by one of my sidebar gadgets. I want these > to be deleted also because the gadget just creates new ones every time > it runs anyway. > solution I suggested consists of exactly two lines. The second line is a very long line. To delete folders: @echo off for /F %%a in ('dir /b /ad "c:\Temporary Files"') do echo rd /s /q "%%a" Again you need to follow this sequence: 1. Create the batch file with the two lines above. 2. Run it from a Command Prompt (not from the Run box!). 3. Satisfy yourself that it would do the right thing. 4. Remove the word "echo" in the second line. Performing Step 4 while ignoring Step 3 is dangerous! |
My System Specs![]() |
| | #5 (permalink) |
| Vista Ultimate SP1 x64 | Re: Script to delete files on shutdown hi, again strangely i couldnt get it to work for some reason. I did a google search & came up with: del %TEMP%\*.* /s /f /q for /d %%x in (%TEMP%\*) DO rmdir /s /q "%%x" but again, it deletes 'Darren.bmp' which idont want it to do. Btw this is my user account picture for some reason in the temp folder, if i delete it & log off, it takes a few seconds to create it before i or someone else can log in again which can get annoying. |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Script to delete files on shutdown "fieseler" <guest@xxxxxx-email.com> wrote in message news:53eee35d8f1e2fac95061ce2df030d38@xxxxxx-gateway.com... Quote: > > hi, > again strangely i couldnt get it to work for some reason. I did a > google search & came up with: > > del %TEMP%\*.* /s /f /q > for /d %%x in (%TEMP%\*) DO rmdir /s /q "%%x" > > but again, it deletes 'Darren.bmp' which idont want it to do. Btw this > is my user account picture for some reason in the temp folder, if i > delete it & log off, it takes a few seconds to create it before i or > someone else can log in again which can get annoying. > > > -- > fieseler first script I gave you, with the "echo" word in place in the second line. |
My System Specs![]() |
| | #7 (permalink) |
| Vista Ultimate SP1 x64 | Re: Script to delete files on shutdown i got it to work last night, but it only runs when its in my temp folder itself, so ends up deleting itself. both versions for cleaning the temp folders & files work fine apart from said problem. Last edited by fieseler; 11-14-2008 at 05:56 AM.. |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Script to delete files on shutdown did you manage to get this figured out? I would also like to know how to get it to work as my temp folder is always overflowing with garbage. "fieseler" wrote: Quote: > > i got it to work last night, but it only runs when its in my temp folder > itself, so ends up deleting itself > > > -- > fieseler > > Pirating MS Vista is a crime & a waste of 97 hours looking for a crack > that doesnt virus your pc! > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Script to delete files on shutdown "Darren" <Darren@xxxxxx> wrote in message news:49C5DDCF-53F7-4E6D-8C85-11BE3EC962FC@xxxxxx Quote: > did you manage to get this figured out? I would also like to know how to > get > it to work as my temp folder is always overflowing with garbage. > del /s /q "%temp%\*.*" |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Script to delete files on shutdown On Nov 14, 6:28*am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: > "Darren" <Dar...@xxxxxx> wrote in message > > news:49C5DDCF-53F7-4E6D-8C85-11BE3EC962FC@xxxxxx > Quote: > > did you manage to get this figured out? I would also like to know how to > > get > > it to work as my temp folder is always overflowing with garbage. > Did you try this simple command? > > del /s /q "%temp%\*.*" for /F %%s in ('dir /b') do del /f /s /q "%docs%\%%s\local settings \temp\*.*" & del /f /s /q "%docs%\%%s\Local Settings\Temporary Internet Files\*.*" for /D %%r in (*) do attrib -H -S "%docs%\%%r\local settings\temp" /S / D & rd /s /q "%docs%\%%r\local settings\temp" & attrib -H -S /S /D "%docs%\%%r\Local Settings\Temporary Internet Files" & rd /s /q "%docs% \%%r\Local Settings\Temporary Internet Files" |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| delete temp files via script - can B added 2 startup | VB Script | |||
| Script to delete folder with specific name and files | VB Script | |||
| Shutdown and startup Hyper-V Virtual Machine via script | Virtual Server | |||
| RE: Shutdown Guest OS Script Problem | Virtual Server | |||
| Group Policy - I need to write a script to run on shutdown | Vista security | |||