# Solved: batch file to delete a folder



## MrCoffee42 (Jun 4, 2013)

Hi, Ive looked around a bit and have seen some posts very close to what i need but Im just starting to play around with batch files and haven't quite been able to patch together something that works yet. 

What Im trying to do is make a batch file to run in windows 7 and delete a folder located in: C:\users\"current user"\AppData\roaming\"folder to delete"

the problem Im running into is i need to be able to run this on several computers and i don't want to have to manually put in the name of the current user every time. Is there a way to do this? Any help would be much appreciated.


----------



## Squashman (Apr 4, 2003)

the current user that is logged into the computer is an environmental variable.
At the cmd prompt type: *set* to see all the environmental variables.


----------



## foxidrive (Oct 20, 2012)

MrCoffee42 said:


> i need to be able to run this on several computers


Is the aim to delete the folder in every user profile on the PC? Or just the current user?


----------



## MrCoffee42 (Jun 4, 2013)

its rare we would have more than one user per system so for now i was looking for just the current user.


----------



## foxidrive (Oct 20, 2012)

As Squashman says, check the system environment variables. This is an example.



```
rd /s /q "%USERPROFILE%\AppData\roaming\folder to delete"
```


----------



## MrCoffee42 (Jun 4, 2013)

thanks for the help guys, that got me pointed in the right direction


----------

