*** Root directory path this.cPath = "IIS://LOCALHOST/W3SVC/1/ROOT" ************************************************************************ * wwIISAdmin :: CreateVirtual ********************************* *** Function: Creates a virtual Directory. *** Assume: cPath must point to the parent virtual directory *** Pass: lcVirtual - Virtual ALias "Wconnect" *** lcPath - Physical DOS path *** llNoExecute - Don't set Execute rights *** llNoAuthBasic - DOn't set Basic Auth *** Return: .T. or .F. ************************************************************************ LPARAMETERS lcVirtual,lcPhysical,llNoExecute, llNoAuthBasic LOCAL lcPath, loVirtual THIS.lError = .F. THIS.oRef = GETOBJECT(THIS.cpath) IF ISNULL(THIS.oRef) THIS.cerrormsg = "Unable to connect to server root." RETURN .F. ENDIF IF EMPTY(lcPhysical) *** Delete the Virtual THIS.oRef.DELETE("IIsWebVirtualDir",lcVirtual) THIS.SAVE() IF THIS.lError RETURN .F. ENDIF RETURN .T. ELSE *** Try to create it loVirtual = THIS.oRef.CREATE("IIsWebVirtualDir",lcVirtual) *** If an error occurred it might exist already IF THIS.lError OR TYPE("loVirtual") # "O" THIS.lError=.F. lcPath = THIS.cpath && Our current relative path *** ADd the virtual path to it and try to connect loVirtual = GETOBJECT(lcPath + "/" + lcVirtual) IF THIS.lError *** Still an error - reconnect to the original path *** and exit THIS.oRef = GETOBJECT(lcPath) RETURN .F. ENDIF ENDIF loVirtual.PATH = lcPhysical loVirtual.AppCreate(.T.) && Make sure our app is In Process loVirtual.AppFriendlyName = lcVirtual loVirtual.AccessRead = .T. loVirtual.AccessExecute = !llNoExecute loVirtual.AuthBasic = !llNoAuthBasic loVirtual.AuthNTLM = .T. THIS.OnCreateVirtual(loVirtual) loVirtual.SetInfo() *** Pass out the reference for the directory THIS.oRef=loVirtual ENDIF RETURN .T.Note this gets more tricky than this though, because you can have multiple Web sites (in which case the 1 in the path needs to be replaced with the Web Site ID) and in IIS 6 you may need to configure an application pool etc.