With this library you can automatically create, configure, start and stop web sites and application pools for your own IIS web server without RunProgram().
Functions:
- CreateIISSite()
- Syntax:
Code: Select all
Result = CreateIISSite(SiteName$, Protocol, IPAddress$, Port, Domain$, Path$, ApplicationPool$, @ErrorOutput$)
- Description: Creates a new website.
- Parameter:
- SiteName$: The name of the website.
- Protocol: Protocol of the website. The following constants can be used:
- #PBEx_IIS_Protocol_HTTP
- #PBEx_IIS_Protocol_HTTPS
- IPAddress$: IP address of the network card. "*" or "" can be passed if the domain is not to be bound to a specific network card.
- Port: The port number.
- Domain$: The domain address.
- Path$: The complete physical path to the directory where the Web site is located.
- ApplicationPool$: The name of an existing application pool.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Example:
Code: Select all
EnableExplicit Global PBEx_IIS #PBEx_IIS_Protocol_HTTP = 0 #PBEx_IIS_Protocol_HTTPS = 1 #PBEx_IIS_Attribute_Site_ApplicationPool = 1 #PBEx_IIS_Attribute_Site_Path = 2 #PBEx_IIS_Attribute_Site_ConnectionTimeout = 3 #PBEx_IIS_Attribute_Site_MaxBandwidth = 4 #PBEx_IIS_Attribute_Site_MaxConnections = 5 #PBEx_IIS_Attribute_Site_MaxUrlSegments = 6 #PBEx_IIS_Attribute_ApplicationPool_AutoStart = 1 #PBEx_IIS_Attribute_ApplicationPool_Enable32BitAppOnWin64 = 2 #PBEx_IIS_Attribute_ApplicationPool_ManagedPipelineMode = 3 #PBEx_IIS_Attribute_ApplicationPool_ManagedRuntimeVersion = 4 #PBEx_IIS_Attribute_ApplicationPool_QueueLength = 5 #PBEx_IIS_Attribute_ApplicationPool_StartMode = 6 CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 PBEx_IIS = OpenLibrary(#PB_Any, "PB.Ex_IIS_x86.dll") CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64 PBEx_IIS = OpenLibrary(#PB_Any, "PB.Ex_IIS_x64.dll") CompilerEndIf If PBEx_IIS Prototype CreateIISSite(SiteName.p-Unicode, Protocol, IPAddress.p-Unicode, Port, Domain.p-Unicode, Path.p-Unicode, ApplicationPool.p-Unicode, ErrorOutput) Global CreateIISSite.CreateIISSite = GetFunction(PBEx_IIS, "CreateIISSite") Prototype DeleteIISSite(SiteName.p-Unicode, ErrorOutput) Global DeleteIISSite.DeleteIISSite = GetFunction(PBEx_IIS, "DeleteIISSite") Prototype StartIISSite(SiteName.p-Unicode, ErrorOutput) Global StartIISSite.StartIISSite = GetFunction(PBEx_IIS, "StartIISSite") Prototype StopIISSite(SiteName.p-Unicode, ErrorOutput) Global StopIISSite.StopIISSite = GetFunction(PBEx_IIS, "StopIISSite") Prototype ExamineIISSite(ErrorOutput) Global ExamineIISSite.ExamineIISSite = GetFunction(PBEx_IIS, "ExamineIISSite") Prototype NextIISSiteEntry(ErrorOutput) Global NextIISSiteEntry.NextIISSiteEntry = GetFunction(PBEx_IIS, "NextIISSiteEntry") Prototype IISSiteEntryName(Output, ErrorOutput) Global IISSiteEntryName.IISSiteEntryName = GetFunction(PBEx_IIS, "IISSiteEntryName") Prototype FinishIISSite(ErrorOutput) Global FinishIISSite.FinishIISSite = GetFunction(PBEx_IIS, "FinishIISSite") Prototype CreateIISApplicationPool(ApplicationPoolName.p-Unicode, ErrorOutput) Global CreateIISApplicationPool.CreateIISApplicationPool = GetFunction(PBEx_IIS, "CreateIISApplicationPool") Prototype DeleteIISApplicationPool(ApplicationPoolName.p-Unicode, ErrorOutput) Global DeleteIISApplicationPool.DeleteIISApplicationPool = GetFunction(PBEx_IIS, "DeleteIISApplicationPool") Prototype StartIISApplicationPool(ApplicationPoolName.p-Unicode, ErrorOutput) Global StartIISApplicationPool.StartIISApplicationPool = GetFunction(PBEx_IIS, "StartIISApplicationPool") Prototype StopIISApplicationPool(ApplicationPoolName.p-Unicode, ErrorOutput) Global StopIISApplicationPool.StopIISApplicationPool = GetFunction(PBEx_IIS, "StopIISApplicationPool") Prototype ExamineIISApplicationPool(ErrorOutput) Global ExamineIISApplicationPool.ExamineIISApplicationPool = GetFunction(PBEx_IIS, "ExamineIISApplicationPool") Prototype NextIISApplicationPoolEntry(ErrorOutput) Global NextIISApplicationPoolEntry.NextIISApplicationPoolEntry = GetFunction(PBEx_IIS, "NextIISApplicationPoolEntry") Prototype IISApplicationPoolEntryName(Output, ErrorOutput) Global IISApplicationPoolEntryName.IISApplicationPoolEntryName = GetFunction(PBEx_IIS, "IISApplicationPoolEntryName") Prototype FinishIISApplicationPool(ErrorOutput) Global FinishIISApplicationPool.FinishIISApplicationPool = GetFunction(PBEx_IIS, "FinishIISApplicationPool") Prototype SetIISSiteAttribute(SiteName.p-Unicode, Attribute, Value.p-Unicode, ErrorOutput) Global SetIISSiteAttribute.SetIISSiteAttribute = GetFunction(PBEx_IIS, "SetIISSiteAttribute") Prototype GetIISSiteAttribute(SiteName.p-Unicode, Attribute, Output, ErrorOutput) Global GetIISSiteAttribute.GetIISSiteAttribute = GetFunction(PBEx_IIS, "GetIISSiteAttribute") Prototype SetIISApplicationPoolAttribute(ApplicationPoolName.p-Unicode, Attribute, Value.p-Unicode, ErrorOutput) Global SetIISApplicationPoolAttribute.SetIISApplicationPoolAttribute = GetFunction(PBEx_IIS, "SetIISApplicationPoolAttribute") Prototype GetIISApplicationPoolAttribute(ApplicationPoolName.p-Unicode, Attribute, Output, ErrorOutput) Global GetIISApplicationPoolAttribute.GetIISApplicationPoolAttribute = GetFunction(PBEx_IIS, "GetIISApplicationPoolAttribute") EndIf Global Output$ = Space(1024) Global ErrorOutput$ = Space(128) ;CreateIISApplicationPool("MyOwnAppPool", @ErrorOutput$) ;DeleteIISApplicationPool("MyOwnAppPool", @ErrorOutput$) ;CreateIISSite("MyOwnSite", #PBEx_IIS_Protocol_HTTP, "", 81, "localhost", "D:\ht-docs\", "DefaultAppPool", @ErrorOutput$) ;DeleteIISSite("MyOwnSite", @ErrorOutput$) ;List all application pool Debug "Application pools:" If ExamineIISApplicationPool(@ErrorOutput$) While NextIISApplicationPoolEntry(@ErrorOutput$) IISApplicationPoolEntryName(@Output$, @ErrorOutput$) Debug Output$ Wend EndIf ;List all web sites Debug "Web sites:" If ExamineIISSite(@ErrorOutput$) While NextIISSiteEntry(@ErrorOutput$) IISSiteEntryName(@Output$, @ErrorOutput$) Debug Output$ Wend EndIf CloseLibrary(PBEx_IIS)
- Syntax:
Code: Select all
Result = DeleteIISSite(SiteName$, @ErrorOutput$)
- Description: Removes an existing website. Before deleting, the specified website is closed. If client connections to this site still exist, it may take a few seconds for all open connections to be released from the web server.
- Parameter:
- SiteName$: The name of an existing website.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = StartIISSite(SiteName$, @ErrorOutput$)
- Description: Starts an existing website.
- Parameter:
- SiteName$: The name of an existing website.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = StopIISSite(SiteName$, @ErrorOutput$)
- Description: Ends an existing website. If client connections to this site still exist, it may take a few seconds for all open connections to be released from the web server.
- Parameter:
- SiteName$: The name of an existing website.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = ExamineIISSite(@ErrorOutput$)
- Description: Starts a list of all existing websites.
- Parameter:
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = NextIISSiteEntry(@ErrorOutput$)
- Description: The next website in the list is determined. This function is only valid within the ExamineIISSite loop.
- Parameter:
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = IISSiteEntryName(@Output$, @ErrorOutput$)
- Description: The name of the website is determined. This function is only valid within the ExamineIISSite loop.
- Parameter:
- @Output$: The name of the website is stored in this variable.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = FinishIISSite(@ErrorOutput$)
- Description: Closes the listing.
- Parameter:
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = SetIISSiteAttribute(SiteName$, Attribute, Value$, @ErrorOutput$)
- Description: Changes the value of the specified attribute.
- Parameter:
- SiteName$: The name of an existing website.
- Attribute: The following constants can be used:
- #PBEx_IIS_Attribute_Site_ApplicationPool
- #PBEx_IIS_Attribute_Site_Path
- #PBEx_IIS_Attribute_Site_ConnectionTimeout
- #PBEx_IIS_Attribute_Site_MaxBandwidth
- #PBEx_IIS_Attribute_Site_MaxConnections
- #PBEx_IIS_Attribute_Site_MaxUrlSegments
- Value$: The value for the change.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = GetIISSiteAttribute(SiteName$, Attribute, @Output$, @ErrorOutput$)
- Description: Determines the value using the attribute.
- Parameter:
- SiteName$: The name of an existing website.
- Attribute: The following constants can be queried:
- #PBEx_IIS_Attribute_Site_ApplicationPool
- #PBEx_IIS_Attribute_Site_Path
- #PBEx_IIS_Attribute_Site_ConnectionTimeout
- #PBEx_IIS_Attribute_Site_MaxBandwidth
- #PBEx_IIS_Attribute_Site_MaxConnections
- #PBEx_IIS_Attribute_Site_MaxUrlSegments
- @Output$: The value is stored in this variable.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = CreateIISApplicationPool(ApplicationPoolName$, @ErrorOutput$)
- Description: Creates a new application pool.
- Parameter:
- ApplicationPoolName$: The name of the application pool.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = DeleteIISApplicationPool(ApplicationPoolName$, @ErrorOutput$)
- Description: Removes an existing application pool.
- Parameter:
- ApplicationPoolName$: The name of the existing application pool.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = StartIISApplicationPool(ApplicationPoolName$, @ErrorOutput$)
- Description: Starts an existing application pool.
- Parameter:
- ApplicationPoolName$: The name of the existing application pool.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = StopIISApplicationPool(ApplicationPoolName$, @ErrorOutput$)
- Description: Terminates an existing application pool.
- Parameter:
- ApplicationPoolName$: The name of the existing application pool.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = ExamineIISApplicationPool(@ErrorOutput$)
- Description: Starts a list of all existing application pools.
- Parameter:
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = NextIISApplicationPoolEntry(@ErrorOutput$)
- Description: The next application pool in the list is determined. This function is only valid within the ExamineIISApplicationPool loop.
- Parameter:
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = IISApplicationPoolEntryName(@Output$, @ErrorOutput$)
- Description: The name of the application pool is determined. This function is only valid within the ExamineIISApplicationPool loop.
- Parameter:
- @Output$: The name of the application pool is stored in this variable.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = FinishIISApplicationPool(@ErrorOutput$)
- Description: Closes the listing.
- Parameter:
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = SetIISApplicationPoolAttribute(ApplicationPoolName$, Attribute, Value$, @ErrorOutput$)
- Description: Changes the value of the specified attribute.
- Parameter:
- ApplicationPoolName$: The name of the existing application pool.
- Attribute: The following constants can be used:
- #PBEx_IIS_Attribute_ApplicationPool_AutoStart
- #PBEx_IIS_Attribute_ApplicationPool_Enable32BitAppOnWin64
- #PBEx_IIS_Attribute_ApplicationPool_ManagedPipelineMode: Integrated, Classic
- #PBEx_IIS_Attribute_ApplicationPool_ManagedRuntimeVersion
- #PBEx_IIS_Attribute_ApplicationPool_QueueLength
- #PBEx_IIS_Attribute_ApplicationPool_StartMode: OnDemand, AlwaysRunning
- Value$: The value for the change.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
Code: Select all
Result = GetIISApplicationPoolAttribute(ApplicationPoolName$, Attribute, @Output$, @ErrorOutput$)
- Description: Determines the value using the attribute.
- Parameter:
- ApplicationPoolName$: The name of the existing application pool.
- Attribute: The following constants can be queried:
- #PBEx_IIS_Attribute_ApplicationPool_AutoStart
- #PBEx_IIS_Attribute_ApplicationPool_Enable32BitAppOnWin64
- #PBEx_IIS_Attribute_ApplicationPool_ManagedPipelineMode: Integrated, Classic
- #PBEx_IIS_Attribute_ApplicationPool_ManagedRuntimeVersion
- #PBEx_IIS_Attribute_ApplicationPool_QueueLength
- #PBEx_IIS_Attribute_ApplicationPool_StartMode: OnDemand, AlwaysRunning
- @Output$: The value is stored in this variable.
- @ErrorOutput$: If an error occurred, the error message is stored in the variable. This variable must be reserved with 128 characters before passing. Maximum return length is 128 characters including the NULL character. If no error description is to be returned for an error, 0 can be passed instead.
- Return value:
- 1: The process was successful.
- Syntax:
- Windows Vista or higher
- .NET Framework 4.5 or higher
- IIS
- Unicode activation (default from PB 5.50)
- Administrator privileges
Download: https://www.rsbasic.de/downloads/downlo ... Ex_IIS.zip
I would be very pleased about feedbacks, improvement suggestions, error messages or wishes. If you want to support me, you can also donate something. Thanks