1.

Solve : Deleting folders through logoff?

Answer»

The problem with the for command is that it uses spaces as default delimiter, that's why only C:\Documents is returned when parsing. Two solutions:

1. specify that all tokens are to be returned like this:

for /f [HIGHLIGHT]"tokens=*"[/highlight] %%i in ('dir /a:d /s /b "%userprofile%\Desktop"') do @ECHO.%%i

or 2. change the delimiter to 'no delimiter'

for /f [highlight]"delims="[/highlight] %%i in ('dir /a:d /s /b "%userprofile%\Desktop"') do @echo.%%i

Hope this information is still useful Actually yes this helps a bunch. This worked like a charm. Thanks

Update:
Almost like a charm. After running the script the folder still exists. I modified the one that you posted and changed the @echo part with rd /s /q %%i. The script gives me a "The system cannot find the file specified." message. What am I doing wrong?Try with quotes:

rd /s /q "%%i"
if it still doesn't work, create a dump like this

Code: [Select]for /f "delims=" %%i in ('dir /a:d /s /b "%userprofile%\Desktop"') do echo.rd /s /q "%%i"&rd /s /q "%%i"

and post it to the forum so I can take a look and help.
That go it. It works great now. Just what I needed. Thank you.Now that I have the deleting folders thing down I have just hit another snag. I caught a user saving internet explorer shortcuts to their desktops and my log off scrtipt is not erasing them. I am unsure of what extension I need to use to get these to delete. My script includes *.lnk files but this shortcut is OBVIOUSLY not one of these as it is not deleting. Here is what my script looks like.

cd "%userprofile%"\Desktop\
del *.doc,*.txt,*.xls,*.lnk,*.exe,*.zip,*.jpg,*.jpeg,*.bmp,*.ppt,*.dat,*.mp*,*.rar,*.pdf,*.tab,*.html,*.htm,*.php
cls
cd %userprofile%
rd /s/q cookies
rd /s/q locals~1\history
rd /s/q locals~1\tempor~1

Everything that I attempt to delete does delete so I know that the del part of the script works fine but the internet shortcut does not delete. I can replicate creating the shortcut by going under the File menu in Internet Exploder and selecting Send then choose "Shortcut to desktop".

You all have PRODUCED great results so far so I'm counting on you again.*.lnk should do it, not sure why it wouldn't work :-?Yeah, I'm stumped to. It must be saved with another file extension. Did you happen to try making the shortcut and attempt to delete it. Maybe it does work and I am doing something wrong?



Discussion

No Comment Found