Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Batch question


  • This topic is locked This topic is locked
4 replies to this topic

#1 Markimoo

Markimoo

  • Banned
  • 94 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:08:59 PM

Posted 23 February 2016 - 12:57 PM

Hi,

 

I'm working on a Batch-script for myself and I got a option to remove temponary files, but it doesn't work right now. What am I doing wrong?

FOR /D %%p IN ("C:\Windows\Temp\*.*") DO rmdir "%%p" /s /q
cd C:\Windows\Temp
del *.* /q /s
timeout /t 5 >nul 2>&1 /nobreak

Do I need to make a reboot in it for this?

 

Also if I empty my downloadsmap using other commands it gives a file called Null.

FOR /D %%p IN ("C:\USERS\%USERNAME%\Downloads\*.*") DO rmdir "%%p" /s /q
cd C:\USERS\%USERNAME%\Downloads\
del *.* /q /s
timeout /t 5 >nul 2>&1 /nobreak

Any advice?



BC AdBot (Login to Remove)

 


#2 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:05:59 AM

Posted 24 February 2016 - 07:54 PM

Use FOR /F and not /D

 

Like this quick one i just did (Havnt tested but would work), this will use the %TMP% system variable to cd to it and then remove everything

@ECHO OFF
ECHO Cleaning TEMP Drive
cd /d %TMP%
FOR /F "tokens=1 delims=" %%X IN ('dir /b') DO (
    ECHO Deleting "%%X"
    del "%%X" /F /Q
    
            )
cd \
ECHo Done!.

Edited by JohnnyJammer, 24 February 2016 - 08:02 PM.


#3 Markimoo

Markimoo
  • Topic Starter

  • Banned
  • 94 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:08:59 PM

Posted 25 February 2016 - 05:36 AM

Thanks,

 

I'll put them in my script and test it. :)

 

Sadly it doens't delete everything or do I need a reboot in it?


Edited by Markimoo, 25 February 2016 - 07:54 AM.


#4 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:05:59 AM

Posted 25 February 2016 - 04:26 PM

That script wont be able to delete files still in use so because its deleting files from the Temp folder, some files will say access denied mate.



#5 Markimoo

Markimoo
  • Topic Starter

  • Banned
  • 94 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:08:59 PM

Posted 26 February 2016 - 06:46 AM

I know, can I make a reboot in it or something?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users