Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to
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 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"
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!


Posted on Saturday, May 8, 2010 8:45 PM Batch files/PowerShell | Back to top

Comments on this post: Batch file to Delete Old Virtual Directories.

# re: Batch file to Delete Old Virtual Directories.
Requesting Gravatar...
thanks for the artice it helps me a lot.
Left by torrent on Feb 14, 2011 7:43 AM

Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: