RunForrestRun
asked on
.bat file to delete folder from All Users Profile
Hello Experts,
I know this has probably been asked before, and I'm not sure if I'm asking in the right zone, but how in the world do you delete a folder from the All Users Profile in a batch file in XP Pro? I have tried all sorts of ways but to no avail.
For example, to delete a folder named "DeleteTest" from the %ALLUSERSPROFILE%\Document s folder, how could I code that? I did find a little code on here that went something like this:
%SystemDrive%
cd \
cd %ALLUSERSPROFILE%\Document s
del "DeleteTest"
However, I played around with it but couldn't get it to work.
Thanks in advance...RunForrestRun
I know this has probably been asked before, and I'm not sure if I'm asking in the right zone, but how in the world do you delete a folder from the All Users Profile in a batch file in XP Pro? I have tried all sorts of ways but to no avail.
For example, to delete a folder named "DeleteTest" from the %ALLUSERSPROFILE%\Document
%SystemDrive%
cd \
cd %ALLUSERSPROFILE%\Document
del "DeleteTest"
However, I played around with it but couldn't get it to work.
Thanks in advance...RunForrestRun
ASKER
Hi Steve,
Many thanks,
I tried it with just this one line that you gave here, but it still didn't work, should I add in this other stuff like below:
%SystemDrive%
cd \
cd %ALLUSERSPROFILE%\Document s
del "%ALLUSERSPROFILE%\Documen ts\DeleteT est" /q /s
RFR
Many thanks,
I tried it with just this one line that you gave here, but it still didn't work, should I add in this other stuff like below:
%SystemDrive%
cd \
cd %ALLUSERSPROFILE%\Document
del "%ALLUSERSPROFILE%\Documen
RFR
All that code is unnecessary because the path is fully qualified by ALLUSERSPROFILE.
Questions:
1) When you said it didn't work. What did you mean? Did you get error messages or any information from DOS?
2) What happens when you do this:
echo %ALLUSERSPROFILE%
3) Does this display any files?
dir "%ALLUSERSPROFILE%\Documen ts\DeleteT est"
Please answer these questions. Thanks :)
Questions:
1) When you said it didn't work. What did you mean? Did you get error messages or any information from DOS?
2) What happens when you do this:
echo %ALLUSERSPROFILE%
3) Does this display any files?
dir "%ALLUSERSPROFILE%\Documen
Please answer these questions. Thanks :)
ASKER
Steve I'm sorry, man you answer fast. (-:
Okay,
with just the one line:
del "%ALLUSERSPROFILE%\Documen ts\DeleteT est" /q /s
all it does is just pop open the cmd window for a split second and closes.
And with this line same thing:
echo %ALLUSERSPROFILE%
Same thing with this line:
dir "%ALLUSERSPROFILE%\Documen ts\DeleteT est"
I can stop it with the pause button on my keyboard but man I have to be FAST. But it's basically doing the same thing with either 3 lines that I have in there.
Okay,
with just the one line:
del "%ALLUSERSPROFILE%\Documen
all it does is just pop open the cmd window for a split second and closes.
And with this line same thing:
echo %ALLUSERSPROFILE%
Same thing with this line:
dir "%ALLUSERSPROFILE%\Documen
I can stop it with the pause button on my keyboard but man I have to be FAST. But it's basically doing the same thing with either 3 lines that I have in there.
ASKER
Oh one more thing, and it's still not deleting the file...
Open a command window and repeat the tests. You can do this by doing Start --> Run --> enter cmd and click OK.
ASKER
Okay I hope I did this right.
I opened up my cmd window and put in the lines one at a time and clicked OK. But after each one I would get a window that popped up and said:
Windows cannot find 'del'. Make sure you typed the name correctly, and then try again.
And then:
Windows cannot find 'echo'. Make sure you typed the name correctly, and then try again.
And then:
Windows cannot find 'dir'. Make sure you typed the name correctly, and then try again.
Let's see were you wanting me to put in each line starting with:
del "%ALLUSERSPROFILE%\Documen ts\DeleteT est" /q /s
I opened up my cmd window and put in the lines one at a time and clicked OK. But after each one I would get a window that popped up and said:
Windows cannot find 'del'. Make sure you typed the name correctly, and then try again.
And then:
Windows cannot find 'echo'. Make sure you typed the name correctly, and then try again.
And then:
Windows cannot find 'dir'. Make sure you typed the name correctly, and then try again.
Let's see were you wanting me to put in each line starting with:
del "%ALLUSERSPROFILE%\Documen
ASKER
I'm sorry Steve what I meant was I tried one line at a time and clicked OK. I know I didn't make my self too clear there at the end.
I was confused by you prior statement:
-----
del "%ALLUSERSPROFILE%\Documen ts\DeleteT est" /q /s
all it does is just pop open the cmd window for a split second and closes.
-----
Specifically, the "all it does is just pop open the cmd window for a split second and closes.
That would indicate that you were not running the commands from the cmd box.
Do you understand what I mean by cmd box? Please follow the instructions I posted to open a cmd box and try again.
-----
del "%ALLUSERSPROFILE%\Documen
all it does is just pop open the cmd window for a split second and closes.
-----
Specifically, the "all it does is just pop open the cmd window for a split second and closes.
That would indicate that you were not running the commands from the cmd box.
Do you understand what I mean by cmd box? Please follow the instructions I posted to open a cmd box and try again.
ASKER
I'M SORRY Steve, I TOTALLY misunderstood,
I DIDN'T have the cmd window open, I was just going Start-->Run and trying to run these tests from the Run command. Now I opened the right cmd window and pasted all the tests in one at a time and hit enter.
The first test didn't return anything.
The second test returned C:\Documents and Settings\All Users
The third test returned this directory information:
Volume is Drive C has no label
Volume serial number is xxxx-xxxx
Directory of C:\Documents and Settings\All Users\Documents\DeleteTest
11/06/2007 11:31 AM <DIR>
11/06/2007 11:31 AM <DIR>
0 files 0 bytes
2 Directories 2 gazillion bytes blah blah blah all that stuff when you do a dos like dir
I deeply apologize my bad
I DIDN'T have the cmd window open, I was just going Start-->Run and trying to run these tests from the Run command. Now I opened the right cmd window and pasted all the tests in one at a time and hit enter.
The first test didn't return anything.
The second test returned C:\Documents and Settings\All Users
The third test returned this directory information:
Volume is Drive C has no label
Volume serial number is xxxx-xxxx
Directory of C:\Documents and Settings\All Users\Documents\DeleteTest
11/06/2007 11:31 AM <DIR>
11/06/2007 11:31 AM <DIR>
0 files 0 bytes
2 Directories 2 gazillion bytes blah blah blah all that stuff when you do a dos like dir
I deeply apologize my bad
ASKER
Steve I really appreciate all your help.
Sorry you had to spend so much time dealing with my mess.
Hope you have a wonderful Thanksgiving. (-:
RFR
Sorry you had to spend so much time dealing with my mess.
Hope you have a wonderful Thanksgiving. (-:
RFR
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Steve,
back from the Thanksgiving holiday. THAT DID IT!! 500 for you buddy. Thank you SOOO much. Tried it first thing this morning and went off without a hitch. I even went in there and recreated the DeleteTest folder ran my batch file again just to see, and deleted it oh so smoothly.
God Bless
RFR
back from the Thanksgiving holiday. THAT DID IT!! 500 for you buddy. Thank you SOOO much. Tried it first thing this morning and went off without a hitch. I even went in there and recreated the DeleteTest folder ran my batch file again just to see, and deleted it oh so smoothly.
God Bless
RFR
ASKER
Good Morning Steve,
back from the Thanksgiving holiday and I want you to know I tried that and it went off without a hitch. You are a genius. I even went in there and recreated the DeleteTest folder, ran my batch file again and it deleted it without a problem. 500 points for you buddy. I really appreciate all your help. Say, I tried to award points for you but it said this was already accepted. Well anyway 500 for you in my book. (-: God Bless and hope you had a wonderful holiday.
RFR
back from the Thanksgiving holiday and I want you to know I tried that and it went off without a hitch. You are a genius. I even went in there and recreated the DeleteTest folder, ran my batch file again and it deleted it without a problem. 500 points for you buddy. I really appreciate all your help. Say, I tried to award points for you but it said this was already accepted. Well anyway 500 for you in my book. (-: God Bless and hope you had a wonderful holiday.
RFR
Thanks :) Glad to help.
The key is the double quotes around the directory since it has spaces in it.