(imported comment written by troyboy91)
brolly33
sgreenwall,
I think I follow you. It sounds like your approach is a little more complicated than it needs to be. Try this on for size:
Relevance for your Fixlet will be:
exists folder whose (name of it = “ICAClient”) of folders of folders of folder “C:\Documents and Settings” and (it = “WinXP” or it=“Win2000”) of Name of Operating System
Action script will be:
DOS for /f “usebackq” %a in (dir /b /a "c:\documents and settings"
) do rd /s /q “c:\documents and settings%a\ICAClient”
This will only work on Windows 2k forward.
That dos command actually pulls a directory of the documents and settings folder and then parses each line and puts it into the %a variable. The /b on the DIR command gives you just a simple list with no headers and the /a gets you hidden folders too. Then for each %a it performs rd /s /q “c:\documents and settings%a\ICAClient”. The beauty of that is that you don’t have to detect what profiles actually have the subdirectory. You just delete any that exist under any profile. Fast and efficient.
To better see how that DOS command works and how I built it, paste these commands into the command window on a test box.
First try this to pull subdirectories of c:\documents and settings:
dir /b /a “c:\documents and settings”
Then this to see the same thing but parsed out into individual echo commands:
for /f “usebackq” %a in (dir /b /a "c:\documents and settings"
) do echo %a
Then this to echo the total path wrapped around each of those subdirectories:
for /f “usebackq” %a in (dir /b /a "c:\documents and settings"
) do echo c:\documents and settings%a\ICAClient
And finally this to perform the actual deletion of each of the subdirectories returned above, whether or not they exist:
for /f “usebackq” %a in (dir /b /a "c:\documents and settings"
) do rd /s /q “c:\documents and settings%a\ICAClient”
You will see some error when the directory does not exist, but it will run to completion and should sucessfully delete all of those folders from all of your profile directories.
For more on the concatenation question, these threads might help:
http://forum.bigfix.com/viewtopic.php?id=73
http://forum.bigfix.com/viewtopic.php?id=170
http://forum.bigfix.com/viewtopic.php?pid=843#p843
Cheers,
Brolly
Hey Guy’s
This is exactly what I have been trying to do…been looking everywhere.
I needed to delete a folder called “sessions” that could have been located under any profile under Documents and settings. I have modified it to work via command line but when i put it in a bat it does not work ? Why is that ?
I have the following modified :
dir /b /a “c:\documents and settings”
for /f “usebackq” %a in (dir /b /a "c:\documents and settings"
) do echo %a
for /f “usebackq” %a in (dir /b /a "c:\documents and settings"
) do echo c:\documents and settings%a\desktop\sessions
for /f “usebackq” %a in (dir /b /a "c:\documents and settings"
) do rd /s /q “c:\documents and settings%a\desktop\sessions”
Firstly I tried renaming folders to short names EG: Document and Settings to DOCUME~1 … But No Go…
When I run it line by line within a DOS window it works , when i add it to my batch file that also deletes the registry entry and folder of the application, It does not work and I get the following error:
\DOCUME~1"`) do rd /s /q “C:\DOCUME~1\a\desktop\sessions” was unexpected at this time.
Cant work it out…At the end of the day I want a batch file to search all user profiles and then search and delete a folder called SESSIONS…Appreciate any assistance…
Cheers