PDA

View Full Version : delete a virtual directory..



karthik_mcc
08-05-2004, 02:02 AM
Hi,
How to check whether a virtual directory exists or not through intelliscript. I know how to create and delete but, if i try to delete a virutual directory which does not exists, then it throws an error.

thanks,

karthik.

Perucho
08-10-2004, 01:16 PM
Could you post the code to create and delete virtual directories?

I am trying to find out how to delete virtual directories.

I have a link here that shows how to create a virtual directory:
http://helpnet.installshield.com/robo/projects/devstudio9helplangref/CoGetObject_example.htm

Maybe the url above can help you, but I would think to check if the Virtual Directory exist maybe you can use CoGetObject() and IsObject().

surgeon
08-11-2004, 04:16 AM
Hi,

i am using this rul-file to check wether a virtual directory exists.
It was written for is dev 8.



prototype NUMBER VirtDirDialog( ); // The Dialog u use
prototype NUMBER CheckVirtDirExists(string); //Function to check


function number CheckVirtDirExists(VDName)

number nTy,bSi,ret;
string mRet,VDir;

begin
VDir = "/" + VDName; //VDName = the value u retrieve through ur dialog
nTy=REGDB_STRING ;
bSi=MAX_PATH;

RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE );
if(RegDBGetKeyValueEx("\\SYSTEM\\CurrentControlSet\\Services\\w3svc\\parameters\\Virtual Roots\\", VDir, nTy, mRet,bSi )<0) then
ret = 0; // The VDirectory does not exists
else
INFORMATION);
ret = 1; // The Directory allready exists
endif;
return ret;
end;




i hope this helps

regards
surge

Perucho
08-11-2004, 09:03 AM
what is the code to delete a virtual directory?

surgeon
08-11-2004, 11:25 AM
Hi,
How to check whether a virtual directory exists or not through intelliscript. I know how to create and delete but, if i try to delete a virutual directory which does not exists, then it throws an error.

thanks,

karthik.



i replied to this question sorry ...
the only thing i got for deletin a virt dir is written in vbs, no intsallscript here sry but u can use the vbs within a custom action.
if u wanna have the vbs let me know,.

Regards
surge

Perucho
08-17-2004, 01:02 PM
I need to know how to delete a virtual directory using InstallScript code.

I have a link that shows how to create a virtual directory:
http://helpnet.installshield.com/robo/projects/devstudio9helplangref/CoGetObject_example.htm

I know how to add a virtual directory from the url above. And now I know how to check if a virtual directory already exists through the registry.

Thanks.

Perucho
08-18-2004, 10:23 AM
Surgeon, can you please post the VBScript to delete a virtual directory.

Thanks!

surgeon
08-18-2004, 02:54 PM
Hi,

this function deletes a virtual directory "MyVirtDir" and its subdirectory "MySubVirtDir". There is no error checking so u may add some.



function DelVirtDir()
Dim objWebServer
Dim objVirtualDir
Dim strAppName
Dim intASPSessionTimeout
Dim SubVirtDir
On Error Resume Next
CreateApplication = ERROR_SUCCESS
strAppName = "MyVirtDir"
SubVirtDir = SubVirtDir + "/MySubVirtDir"
intASPSessionTimeout = 120
Set objWebServer = GetObject("IIS://localhost/W3SVC/1/Root")
'Delete the Virtual subdirectory
Set objVirtualDir = objWebServer.Delete("IISWebVirtualDir", SubVirtDir)
Set objVirtualDir = objWebServer.Delete("IISWebVirtualDir", strAppName)
End Function


btw the link you posted for creating a virtual directory using installscript looks very familiar ;)


......
set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");
if (IsObject(objIIS_Root)) then
try
set objVirtDir = objIIS_Root.Create("IISWebVirtualDir", VIRTUALDIR);
.......

did u try


......
set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");
if (IsObject(objIIS_Root)) then
try
set objVirtDir = objIIS_Root.Delete("IISWebVirtualDir", VIRTUALDIR);
.......

:confused:

Regards
surge

Perucho
08-18-2004, 04:17 PM
Thanks Surgeon!

But of course after spending a lot of time with VBScript and getting it to work, I discover what I was looking for:

function functionName(sVDName)
OBJECT objIIS_Root;
begin

set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");

if (IsObject(objIIS_Root)) then
objIIS_Root.Delete("IISWebVirtualDir", sVDName);
else
// objIIS_Root has not been assigned a reference to a valid object.
endif;

end;

Christopher Painter
08-18-2004, 06:23 PM
Anything written in VBScript can easily be ported to InstallScript. Post your example and I can do it for you as an example.

chrisgwilliams
01-26-2005, 10:35 AM
could SOMEONE please post some IS to delete a virtual directory?

C.

Perucho
01-26-2005, 05:03 PM
It's posted already : http://community.installshield.com/showpost.php?p=289154&postcount=9