Search This Blog

Monday, December 20, 2010

How to delete directories using wildcards

This script is also useful for deleting user profiles from Citrix servers (since they could be C:\Documents and Settings\UserID, C:\Documents and Settings\UserID.DOMAIN,  C:\Documents and Settings\UserID.old etc - last usually happens if somebody renames them)

It's a bit tricky since rmdir doesn't support wildcards.
Also , "CD" doesn't work with UNC path, so you either can do the registry fix described here or just use pushd /popd as I did.


rem Usage : DelCtxprof.cmd UserID

IF (%1)==() GOTO ERR

Pause This batch file will delete all profiles that start with "%1%" from all Citrix servers. If you don't want to do it, press Ctrl-C

pushd "\\CitrixServer1\C$\Documents and settings\"
for /d %%a in (%1*) do rd /s /q "%%~a"

rem Do the rest of your citrix servers there


ECHO Please specify User ID !!!

No comments:

Post a Comment