Batch file to Delete Old Virtual Directories.

Posted by Michael Freidgeim on Geeks with Blogs See other posts from Geeks with Blogs or by Michael Freidgeim
Published on Sun, 09 May 2010 01:45:32 GMT Indexed on 2010/05/11 2:55 UTC
Read the original article Hit count: 363

Filed under:
On some servers we have many old Virtual Directories created for previous versions of our application.
IIS user interface allows to delete only one in a time.
Fortunately we can use IIS scripts as described in

How to manage Web sites and Web virtual directories by using command-line scripts in IIS 6.0

I've created batch file DeleteOldVDirs.cmd

rem http://support.microsoft.com/kb/816568
rem syntax: iisvdir /delete WebSite [/Virtual Path]Name [/s Computer [/u [Domain\]User /p Password]]

REM list all directories and create batch of deletes
iisvdir /query "Default Web Site"

echo "Enter Ctrl-C  if you want to stop deleting"
Pause
iisvdir /delete "Default Web Site/VDirName1"

iisvdir /delete "Default Web Site/VDirName2"
...

 
If the name of WebSite or Virtual directory contain spaces(e.g  "Default Web Site"), don't forget to use double quotes.
Note that the batch doesn't delete physical directories from flie system.You need to delete them using Windows Explorer, but it does support multiple selection!


 

© Geeks with Blogs or respective owner