Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm looking for a way to change the physical path of a virtual directory in IIS6. Basically, the IIS6 version of this IIS7 call

c:\Windows\System32\inetsrv\appcmd set VDIR 
    "Default Web Site/MySite/" "/physicalPath:c:\NewPath"

Is there a way to do this or do I have to delete the virtual directory and recreate it?

share|improve this question
add comment

3 Answers 3

You'll want to use adsutil.vbs for this. It should be in c:\inetpub\adminscripts\

The command line is:


cscript adsutil.vbs SET W3SVC1/<WebSiteNum>/Root/<Vdirname>/Path "<new physical path>"
share|improve this answer
    
Since appcmd was not installed on Strop's server, it is likely that adsutil was also not installed, as they both rely on IIS 6 Metabase compatibility components under IIS7. –  Jessica McKinnon Aug 26 '09 at 15:16
1  
He specifically stated he is on IIS6 though, where appcmd doesn't exist. –  MattB Aug 26 '09 at 15:23
add comment

I had the same question today: "how do you change the path to an IIS6 vdir using the command line?"

My solution was to make my own vbs. To use it just pass the vdir name and path. So if I had a vdir called "Web" and wanted to change the path to "d:\theNewPath\to\Website", then I would run the following command in the command prompt:

updateVDirPath web d:\theNewPath\to\Website

Also, to check the path of the Vdir, just pass the vdir name:

updateVDirPath web

So here are the contents to updateVDirPath.vbs

If WScript.Arguments.Count = 0 or WScript.Arguments.Count > 2  Then
    WScript.Echo "To check the vDirs path, call updateVDirPath <vDir>" & vbCrLf & "To update the vDir's path, call updateVDirPath <vDir> <newPath>"
Else
    set providerObj = GetObject("winmgmts://localhost/root/MicrosoftIISv2") 
    set IIsWebVirtualDirSettingObj = providerObj.get("IIsWebVirtualDirSetting='W3SVC/1/ROOT/" & WScript.Arguments(0) & "'") 

    If WScript.Arguments.Count = 1 Then
        WScript.Echo "Current path is: " & IIsWebVirtualDirSettingObj.Path
    Else
        IIsWebVirtualDirSettingObj.Path = WScript.Arguments(1)
        IIsWebVirtualDirSettingObj.Put_ () 
    End If
End If
share|improve this answer
add comment

You can still use the same command in IIS7, as long as you have installed the IIS6 management compatibility components (these are not installed by default, but can be added via the Add/Remove Windows Features Wizard or the Server Manager tool).

Alternatively, you can directly modify the web.config file in the parent folder (or possibly higher up the tree) where the virtual folder was defined.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.