Foliotek Development Blog

Rename Applications and Virtual Directories in IIS7

by Brian Grinstead

Have you ever wondered why the box to change the name or “Alias” on an application or virtual directory is greyed out (see screenshot below)? I found a way to change the name without recreating all your settings. It uses the built in administration commands in IIS7, called appcmd.

Renaming Applications In IIS7

  1. Open a command prompt to see all of your applications.
    C:> %systemroot%\system32\inetsrv\appcmd list app
    APP "Default Web Site/OldApplicationName"
    APP "Default Web Site/AnotherApplication"
  2. Run a command like this to change your “OldApplicationName” path to “NewApplicationName”. Now you can use http://localhost/newapplicationname
    C:> %systemroot\%system32\inetsrv\appcmd set app "Default Web Site/OldApplicationName" -path:/NewApplicationName;
    APP object "Default Web Site/OldApplicationName" changed

Renaming Virtual Directories In IIS7

  1. Open a command prompt to see all of your virtual directories.
    C:> %systemroot%\system32\inetsrv\appcmd list vdir
    VDIR "Default Web Site/OldApplicationName/Images" (physicalPath:\serverimages)
    VDIR "Default Web Site/OldApplicationName/Data/Config" (physicalPath:\serverconfig)

    We want to rename /Images to /Images2 and /Data/Config to /Data/Config2. Here are the example commands:

    C:> %systemroot%\system32\inetsrv\appcmd set vdir "Default Web Site/OldApplicationName/Images" -path:/Images2
    VDIR object "Default Web Site/OldApplicationName/Images" changed
    C:> %systemroot%\system32\inetsrv\appcmd set vdir "Default Web Site/OldApplicationName/Data/Config" -path:/Data/Config2
    VDIR object "Default Web Site/OldApplicationName/Data/Config" changed

Tags: , , , , , , , , ,

« »

6 Responses to “Rename Applications and Virtual Directories in IIS7”

  1. Taneka Stumpp Says:

    Good to know, keep it up.

  2. Rizwan Says:

    Use this instead. The above command has some copy paste errors:
    e.g. to rename a virtual directory named “OLDNAME” to “NEWNAME” you should run:

    %systemroot%system32inetsrvappcmd set app “Default Web Site/OLDNAME” -path:/NEWNAME

  3. Brian Grinstead » Blog Archive » Rename Applications and Virtual Directories in IIS7 Says:

    [...] this is a cross posting from my article at the foliotek devblog. This improves some of the code [...]

  4. Timothy Ewin Says:

    I think this line is incorrect:

    C:> %systemroot%system32inetsrvappcmd list appcmd

    and should be

    C:> %systemroot%system32inetsrvappcmd list vdir

  5. Brian Grinstead Says:

    Thanks Timothy! I had removed the code highlighting as it was messing up the output, and must have mistyped. It is fixed now.

  6. Firoz Says:

    This came in handy, thanks very much.

Leave a Reply