I am a beginner to InstallShield. I am developing a Standard project using InstallShield Developer 7.0.
Will anyone please help me know how to create and remove virtual directory during run-time using InstallScript?
Also, I want to know if there is a possibility to change the IIS virtual directory's properties during runtime using InstallScript.
Thanks.
- Sathish
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Handling IIS virtual directory using InstallScript
Started by
sathishc_cit
, Nov 22 2004 05:09
1 reply to this topic
Posted 01 December 2004 - 18:36
There really is not any support for Virtual Directories in IS Pro 7. Apparently, The 9.5 version does have support, but I wasn't williong to spend another $1000 to get that version right after I bought 7.
I use vbscript to create the directories and set permissions for the virtual directories I need. You can find pretty good tutorials over at MSDN, but I also included what I use to get you started. (Note: the vbscript is just plain ugly but it works and I never went back to clean it up.)
I launch my script with these lines of code in the installer
I use vbscript to create the directories and set permissions for the virtual directories I need. You can find pretty good tutorials over at MSDN, but I also included what I use to get you started. (Note: the vbscript is just plain ugly but it works and I never went back to clean it up.)
I launch my script with these lines of code in the installer
CODE |
szLaunchApp = WINSYSDIR^"wscript.exe"; szCmdLine = SUPPORTDIR^"vdcreator.vbs"; nResult =LaunchAppAndWait(szLaunchApp,szCmdLine,LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN); |
I make sure I use wscript to launch the vbs file to ensure that the host machine did not turn off support for vbscript for security reasons
and here is the code in vdcreator.vbs
CODE |
' File name: CreateIISApp.vbs ' Set some variables and constants we will use... Dim strVirtualDirectoryName1 'IIS Virtual Directory Name Dim strVirtualDirectoryName2 'IIS Virtual Directory Name Dim strVirtualDirectoryName3 'IIS Virtual Directory Name Dim blnInProcessApplication 'IIS In Process Application Flag Dim objIIS 'ADSI IIS Object Dim strVirtualDirectoryPath1 'IIS Virtual Directory Path Dim strVirtualDirectoryPath2 'IIS Virtual Directory Path Dim strVirtualDirectoryPath3 'IIS Virtual Directory Path Dim objFileSystem 'VBScript FileSystemObject Dim strOwner 'NT Folder Owner Dim objVirtualDirectory1 'ADSI IIS Virtual Directory Object Dim objVirtualDirectory2 'ADSI IIS Virtual Directory Object Dim objVirtualDirectory3 'ADSI IIS Virtual Directory Object Dim blnScriptPermissions 'IIS script permissions flag Dim blnExecutePermissions ' IIS Execute permissions flag Dim blnWritePermissions ' Dim blnReadPermissions ' Dim strHTTPReferer 'IIS Referrer Page Dim objWSH 'Windows Scripting Host Object Dim objRTC 'Return Dim strACLCommand 'Command Line string to set ACLs Dim MachineName ' computer name strVirtualDirectoryName1 = "evConfigurationService" strVirtualDirectoryName2 = "evTransactionService" strVirtualDirectoryName3 = "evAccountService" ' Get the Computer name using Wscript.Network and assign to IUSR to create IIS IUSR account name Set WshNetwork = WScript.CreateObject("WScript.Network") MachineName=WshNetwork.ComputerName strOwner = "IUSR_" & MachineName Set WshNetwork = Nothing set wsc = Wscript.CreateObject("WScript.Shell") blnScriptPermissions = "True" blnExecutePermissions = "True" blnWritePermissions = "True" blnReadPermissions = "True" ' Does this IIS application already exist in the metabase? On Error Resume Next Set objIIS = GetObject("IIS://localhost/W3SVC/1/Root/" & strVirtualDirectoryName1) If Err.Number = 0 Then Wscript.echo ("An application with this name already exists. ") Wscript.quit End If Set objIIS = Nothing ' Does this IIS application already exist in the metabase? On Error Resume Next Set objIIS = GetObject("IIS://localhost/W3SVC/1/Root/" & strVirtualDirectoryName2) If Err.Number = 0 Then Wscript.echo ("An application with this name already exists. ") Wscript.quit End If Set objIIS = Nothing ' Does this IIS application already exist in the metabase? On Error Resume Next Set objIIS = GetObject("IIS://localhost/W3SVC/1/Root/" & strVirtualDirectoryName3) If Err.Number = 0 Then Wscript.echo ("An application with this name already exists. ") Wscript.quit End If Set objIIS = Nothing 'Now use IIS administration objects to create the IIS application in the metabase. 'Create the IIS application Set objIIS = GetObject("IIS://localhost/W3SVC/1/Root") strVirtualDirectoryPath1 = objIIS.Path & "\" & strVirtualDirectoryName1 ' First check for and optionally create the physical folder under wwwroot Set objFileSystem = Wscript.CreateObject("Scripting.FileSystemObject") On Error Resume Next Set Folder = objFileSystem.GetFolder(strVirtualDirectoryPath1) If Hex(Err.number) = "4C" Then set f= objFileSystem.CreateFolder(strVirtualDirectoryPath1) End If Set objFileSystem = Nothing 'Create the IIS application strVirtualDirectoryPath2 = objIIS.Path & "\" & strVirtualDirectoryName2 ' First check for and optionally create the physical folder under wwwroot Set objFileSystem = Wscript.CreateObject("Scripting.FileSystemObject") On Error Resume Next Set Folder = objFileSystem.GetFolder(strVirtualDirectoryPath2) If Hex(Err.number) = "4C" Then set f= objFileSystem.CreateFolder(strVirtualDirectoryPath2) End If Set objFileSystem = Nothing strVirtualDirectoryPath3 = objIIS.Path & "\" & strVirtualDirectoryName3 ' First check for and optionally create the physical folder under wwwroot Set objFileSystem = Wscript.CreateObject("Scripting.FileSystemObject") On Error Resume Next Set Folder = objFileSystem.GetFolder(strVirtualDirectoryPath3) If Hex(Err.number) = "4C" Then set f= objFileSystem.CreateFolder(strVirtualDirectoryPath3) End If Set objFileSystem = Nothing 'Using IIS Administration object , turn on script/execute permissions and define the virtual directory as an 'in-process application. Set objVirtualDirectory1 = objIIS.Create("IISWebVirtualDir", strVirtualDirectoryName1) objVirtualDirectory1.AccessScript = blnScriptPermissions objVirtualDirectory1.Path = strVirtualDirectoryPath1 objVirtualDirectory1.AppCreate blnInProcessApplication objVirtualDirectory1.AccessWrite = blnWritePermissions objVirtualDirectory1.AccessRead = blnReadPermissions objVirtualDirectory1.AccessExecute = blnExecutePermissions objVirtualDirectory1.AuthAnonymous =True objVirtualDirectory1.AnonymousUserName=strOwner objVirtualDirectory1.AnonymousPasswordSync=True objVirtualDirectory1.AppCreate (True) objVirtualDirectory1.SetInfo 'Set Change Permissions for the owner using CACLS.exe ' need to "|" pipe the "Y" yes answer to the command "Are you sure?" prompt for this to work (see KB: Q135268 ) strACLCommand = "cmd /c echo y| CACLS " strACLCommand = strACLCommand & strVirtualDirectoryPath1 strACLCommand = strACLCommand & " /g " & strOwner & ":C" Set objWSH = Server.CreateObject("WScript.Shell") objRTC = objWSH.Run (strACLCommand , 0, True) Set objWSH = Nothing 'Using IIS Administration object , turn on script/execute permissions and define the virtual directory as an 'in-process application. Set objVirtualDirectory2 = objIIS.Create("IISWebVirtualDir", strVirtualDirectoryName2) objVirtualDirectory2.AccessScript = blnScriptPermissions objVirtualDirectory2.Path = strVirtualDirectoryPath2 objVirtualDirectory2.AppCreate blnInProcessApplication objVirtualDirectory2.AccessWrite = blnWritePermissions objVirtualDirectory2.AccessRead = blnReadPermissions objVirtualDirectory2.AccessExecute = blnExecutePermissions objVirtualDirectory2.AuthAnonymous =True objVirtualDirectory2.AnonymousUserName=strOwner objVirtualDirectory2.AnonymousPasswordSync=True objVirtualDirectory2.AppCreate (True) objVirtualDirectory2.SetInfo 'Set Change Permissions for the owner using CACLS.exe ' need to "|" pipe the "Y" yes answer to the command "Are you sure?" prompt for this to work (see KB: Q135268 ) strACLCommand = "cmd /c echo y| CACLS " strACLCommand = strACLCommand & strVirtualDirectoryPath2 strACLCommand = strACLCommand & " /g " & strOwner & ":C" Set objWSH = Server.CreateObject("WScript.Shell") objRTC = objWSH.Run (strACLCommand , 0, True) Set objWSH = Nothing 'Using IIS Administration object , turn on script/execute permissions and define the virtual directory as an 'in-process application. Set objVirtualDirectory3 = objIIS.Create("IISWebVirtualDir", strVirtualDirectoryName3) objVirtualDirectory3.AccessScript = blnScriptPermissions objVirtualDirectory3.Path = strVirtualDirectoryPath3 ' Added the next line since the above line does not always work 'objVirtualDirectory3.Put "Path", (strVirtualDirectoryPath3) objVirtualDirectory3.AppCreate blnInProcessApplication objVirtualDirectory3.AccessWrite = blnWritePermissions objVirtualDirectory3.AccessRead = blnReadPermissions objVirtualDirectory3.AccessExecute = blnExecutePermissions objVirtualDirectory3.AuthAnonymous =True objVirtualDirectory3.AnonymousUserName=strOwner objVirtualDirectory3.AnonymousPasswordSync=True objVirtualDirectory3.AppCreate (True) objVirtualDirectory3.SetInfo 'Set Change Permissions for the owner using CACLS.exe ' need to "|" pipe the "Y" yes answer to the command "Are you sure?" prompt for this to work (see KB: Q135268 ) strACLCommand = "cmd /c echo y| CACLS " strACLCommand = strACLCommand & strVirtualDirectoryPath3 strACLCommand = strACLCommand & " /g " & strOwner & ":C" Set objWSH = Server.CreateObject("WScript.Shell") objRTC = objWSH.Run (strACLCommand , 0, True) Set objWSH = Nothing |
HTH
There is great chaos under heaven, and the situation is excellent. (Mao Tse Tung)