Computing.Net > Forums > Programming > Logoff script erase folders

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Logoff script erase folders

Reply to Message Icon

Name: jonez34
Date: February 16, 2006 at 08:13:54 Pacific
OS: Windows 2000
CPU/Ram: intel 256 mb ram
Product: IBM
Comment:

I currently have a logoff script that erases shortcuts off a users desktop and leaves only the All Users shortcuts which admins can control. The only issue is that I have noticed that users have been saving folders to the desktop I cannot figure out a way to delete them off the desktop. I have tried the following script with no luck.

cd "%userprofile%"\Desktop
rd *.* /s /q

Any ideas?




Sponsored Link
Ads by Google

Response Number 1
Name: shahramsh
Date: February 17, 2006 at 15:37:18 Pacific
Reply:

this:
rd "%userprofile%"\Desktop /s /q should remove the whole destop folder with the subfolders and files,

but if you want to remove the individual folders, this should work in an english windows:

@echo off
cd "%userprofile%"\Desktop
if "%1"==":rd" goto rd
if exist %temp%\temprd01.tmp del %temp%\temprd01.tmp >nul
dir /a:d | find "<DIR>" | find /v "<DIR> .." | find /v "<DIR> .">%temp%\temprd01.tmp
for /f "tokens=2 delims=<DIR>" %%I in (%temp%\temprd01.tmp) do call %0 :rd %%I
:rd
if "%2"=="" goto EOF
set var=%*
set var=%var:~14%
rd "%var%" /s /q
:EOF


0

Response Number 2
Name: shahramsh
Date: February 17, 2006 at 16:21:38 Pacific
Reply:

sorry and easier way,
just forgot about "/b" in dir,

@echo off
cd "%userprofile%"\Desktop
if exist %temp%\temprd01.tmp del %temp%\temprd01.tmp >nul
dir /a:d /b >%temp%\temprd01.tmp
for /f "delims=" %%I in (%temp%\temprd01.tmp) do rd "%%I" /s /q


0

Response Number 3
Name: shahramsh
Date: February 17, 2006 at 16:24:57 Pacific
Reply:

even easier :

@echo off
for /f "delims=" %%I in ('dir /a:d /b') do rd "%%I" /s /q


0

Response Number 4
Name: jonez34
Date: February 20, 2006 at 16:00:03 Pacific
Reply:

Thanks for the info. This is really gonna help. I can't thank you guys enough.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Batchfile prefix multiple... VB sub paramters



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Logoff script erase folders

code for get logoff script from server www.computing.net/answers/programming/code-for-get-logoff-script-from-server/2452.html

Batch File with Logoff scripts www.computing.net/answers/programming/batch-file-with-logoff-scripts/15459.html

Delete folders using .vbs script www.computing.net/answers/programming/delete-folders-using-vbs-script/10767.html