NsisIIS plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
 
(30 intermediate revisions by 10 users not shown)
Line 2: Line 2:


== Links ==
== Links ==
<attach>NsisIIS.zip</attach>
<br>
<br>
[http://toranj.sourceforge.net  Nsis IIS plugin]
[http://toranj.sourceforge.net  Nsis IIS plugin page on SourceForge]


== Description ==
== Description ==
Line 12: Line 15:


Instructions:<br>
Instructions:<br>
- Copy '''NsisIIS.dll''' to Pluginsfolder of Nsis
- Copy '''NsisIIS.dll''' to Plugins folder of Nsis
- Read this readme and example files.
- Read this readme and example files.


Line 25: Line 28:


Example: NsisIIS::CreateVDir "VDir Name" "Physical Path"
Example: NsisIIS::CreateVDir "VDir Name" "Physical Path"
Optional arguments:
<br>
*$1 “Application Pool” name. This is necessary when working with IIS 6 or higher, in which there are different predefined pools. Your asp.net application, usually uses “Classic .NET AppPool”
<br>
*$2 “Access Flags”. This is a string describing required access permissions on IIS metabase.
<br>
r=read
<br>
w=write
<br>
s=run script
<br>
e=run executable
<br>
c=script source access
<br>
b=directory browsing
<br>
Your string must be a concatenation of these letters. for example: ‘rs’ is default for ASP.net  applications.
<br>
*$3 “Default Documents” A comma separated list of default documents. Anyone used IIS know what this is.
<br>
*$4 “IPSecurity” is a special string we have provided to let the plug-in put IP/Domain access restrictions in place. The first word makes the default behavior. “Grant” means by default all clients are allowed, and the coming items (IP or Domain) are ones who are restricted. “Deny” means the contrary, e.g. all clients are denied access, except the following ones. Here are
some examples:
<br>
Grant All Except (123.123.123.0) (10.10.10.0, 255.255.255.0) (mydomain.net)
<br>
Deny All Except (123.321.123.5, 255.255.255.192) (stranger.mydomain.net)
<br>
Note that the first IP address can be a single client address or a network entry ip, in which case the next item in the parenthesis is (after comma) the net-mask parameter. Each IP or Domain must be surrounded with parenthesis, and between each item must be space.
<br>
*$5 SSL Access flags. Currently not working. This feature will be available in the next minor version.
<br>
Extra variables may be added in next versions of this project, since IIS has much more settings to be added.


===NsisIIS::DeleteVDir===
===NsisIIS::DeleteVDir===
Line 31: Line 70:
After calling, you MUST Pop the message, it can be the success or fail message.
After calling, you MUST Pop the message, it can be the success or fail message.


Example: NsisIIS::DeletVDir "VDir Name"
Example: NsisIIS::DeleteVDir "VDir Name"


===NsisIIS::GetVDir===
===NsisIIS::GetVDir===
Line 39: Line 78:


Example: NsisIIS::GetVdir "VDir Name"
Example: NsisIIS::GetVdir "VDir Name"
===NsisIIS::ListVDirs===
Gets a list of IIS Virtual Directory names, as a comma separated string.
Example: NsisIIS::ListVDirs


===NsisIIS::Start===
===NsisIIS::Start===
Line 67: Line 111:


Example: NsisIIS::Resume
Example: NsisIIS::Resume
===NsisIIS::GetIIsInfo===
Gets IIS Information. Currently only the version as "major.minor" string in $0.
Example: NsisIIS::GetIIsInfo
===NsisIIS::ListWebSites===
Tries to get a list of IIS Web Site names, as comma separated "Id:Title" items into $1. Note that in ADSI (and metabase) websites are identified by their index (id), not the name (title or comment).
Example: NsisIIS::ListWebSites
===NsisIIS::CreateWebSite===
Creates a website getting its Name (Title), Physical Path, and Bindings respectively. Other optional parameters can be fed into $1 through $4. Bindings are in the format of ADSI standard: hostname:ip:port. The following line creates a website at port 8000, all headers and all assigned IPs.
Example:
  StrCpy $1 "Classic .NET AppPool"
  StrCpy $2 "rs"
  StrCpy $3 "MyWebPage.htm" ;Multiple documents must have a ", " separator.
  NsisIIS::CreateWebSite "MyWebSite" "D:\WebSite2" "*:8000:"
  pop $0
For default document, "default.asp, default.htm" will function properly but "default.asp default.htm" or "default.asp,default.htm" will not.
NsisIIS::CreateWebSite sets "ServerBindings" Metabase parameter in C++, which accepts string format as "IP:Port:Hostname" (Microsoft Metabase Property ref.). Latest NsisIIS code(v2.0.1) has a bug to skip 1st character if no comma(,) is found. So we must pass "*" or " " in beginning of string to make it work.
===NsisIIS::DeleteWebSite===
Deletes a website by getting its 1 based index (id).
Example:
  NsisIIS::DeleteWebSite "2"
  pop $0
===NsisIIS::GetWebSite===
Gets a website information by getting its index (id). Result can be accessed via $0 through $5.
Example: NsisIIS::GetWebSite "2"
===NsisIIS::ListAppPools===
Lists all available IIS Application Pools as comma separated list of their names in $1.
Example: NsisIIS::ListAppPools
===NsisIIS::CreateAppPool===
Creates an Application Pool getting its name, and optionally other information through $1 to $3.
Example: NsisIIS::CreateAppPool "MyAppPool"
$1 Sets: .Net Framework Version, ex. "v2.0", "v4.0"
$2 Sets: Managed Pipeline Mode to "Classic" or "Integrated"
$3 Sets: Enable32BitApplications to "true" or "false"
For .Net Framework Version, word document example says "2", "4" which does not work.
Source code (v2.0.1) sets managedRuntimeVersion property in C++,which must be in format of vX.Y  http://technet.microsoft.com/en-us/library/cc754523(WS.10).aspx)
===NsisIIS::DeleteAppPool===
Deletes an Application Pool getting its ID.
Example: NsisIIS::DeleteAppPool "MyAppPool"
===NsisIIS::GetAppPool===
Tries to get an Application Pool information getting its name, and returning the result in variables $1 through $3.
Example: NsisIIS::GetAppPool "MyAppPool"
$1 Returns: ?
$2 Returns: .Net Framework Version
$3 Returns: Managed Pipeline Mode


== TODO ==
== TODO ==
*Adding support for Virtual Directories inside a Web Site.
*Adding support for managing another machine (not local) IIS.
*Adding support for SSL & authentication settings.
*Adding support for SSL & authentication settings.
*Adding support for IIS 8


== History ==
== History ==
2/24/2010 Released version 1.0.0 & used in my installer.
*2/24/2010 Released version 1.0.0 & used in my installer.
*7/21/2011 Released version 2.0.0 & used in my installer.
 
== Alternatives ==
 
If the NsisIIS plugin lacks a capability that you need, you can always call appcmd.exe IIS administration tool directly from an install script, like so:
 
  ExecWait '"$WINDIR\system32\inetsrv\appcmd.exe" < arguments >'
 
Documentation for appcmd is available at http://technet.microsoft.com/en-us/library/cc772200%28v=ws.10%29.aspx


[[Category:Plugins]]
[[Category:Plugins]]

Latest revision as of 18:21, 28 March 2014

Author: Kamyar (talk, contrib)


Links

NsisIIS.zip (16 KB)


Nsis IIS plugin page on SourceForge

Description

Version: 1.0.0

NsisIIS plugin to create/edit/delete/getinfo Microsoft IIS virtual directories and manage it's service status

Instructions:
- Copy NsisIIS.dll to Plugins folder of Nsis - Read this readme and example files.

Functions

NsisIIS::CreateVDir

Creates an IIS virtual directory and sets its configuration, or just set the configuration if it already exists.

After calling, you MUST Pop the message, it can be the success or fail message. You can also put the settings to Nsis user variables $1 through $5. See the documentation for details.

Example: NsisIIS::CreateVDir "VDir Name" "Physical Path"


Optional arguments:

  • $1 “Application Pool” name. This is necessary when working with IIS 6 or higher, in which there are different predefined pools. Your asp.net application, usually uses “Classic .NET AppPool”


  • $2 “Access Flags”. This is a string describing required access permissions on IIS metabase.


r=read
w=write
s=run script
e=run executable
c=script source access
b=directory browsing
Your string must be a concatenation of these letters. for example: ‘rs’ is default for ASP.net applications.

  • $3 “Default Documents” A comma separated list of default documents. Anyone used IIS know what this is.


  • $4 “IPSecurity” is a special string we have provided to let the plug-in put IP/Domain access restrictions in place. The first word makes the default behavior. “Grant” means by default all clients are allowed, and the coming items (IP or Domain) are ones who are restricted. “Deny” means the contrary, e.g. all clients are denied access, except the following ones. Here are

some examples:
Grant All Except (123.123.123.0) (10.10.10.0, 255.255.255.0) (mydomain.net)
Deny All Except (123.321.123.5, 255.255.255.192) (stranger.mydomain.net)
Note that the first IP address can be a single client address or a network entry ip, in which case the next item in the parenthesis is (after comma) the net-mask parameter. Each IP or Domain must be surrounded with parenthesis, and between each item must be space.

  • $5 SSL Access flags. Currently not working. This feature will be available in the next minor version.


Extra variables may be added in next versions of this project, since IIS has much more settings to be added.

NsisIIS::DeleteVDir

Deletes an IIS virtual directory by its name. After calling, you MUST Pop the message, it can be the success or fail message.

Example: NsisIIS::DeleteVDir "VDir Name"

NsisIIS::GetVDir

Gets an IIS virtual directory configuration (if exists) and put it into user variables $1 through $5. See the documentation for details. After calling, you MUST Pop the message, it can be the success or fail message.

Example: NsisIIS::GetVdir "VDir Name"

NsisIIS::ListVDirs

Gets a list of IIS Virtual Directory names, as a comma separated string.

Example: NsisIIS::ListVDirs

NsisIIS::Start

Tries to start IIS service if stopped. After calling, you MUST Pop the message, it can be the success or fail message.

Example: NsisIIS::Start

NsisIIS::Stop

Tries to stop IIS service if started. After calling, you MUST Pop the message, it can be the success or fail message.

Example: NsisIIS::Stop

NsisIIS::Pause

Tries to pause IIS service if running. After calling, you MUST Pop the message, it can be the success or fail message.

Example: NsisIIS::Pause

NsisIIS::Resume

Tries to resume IIS service after calling Pause. After calling, you MUST Pop the message, it can be the success or fail message.

Example: NsisIIS::Resume

NsisIIS::GetIIsInfo

Gets IIS Information. Currently only the version as "major.minor" string in $0.

Example: NsisIIS::GetIIsInfo

NsisIIS::ListWebSites

Tries to get a list of IIS Web Site names, as comma separated "Id:Title" items into $1. Note that in ADSI (and metabase) websites are identified by their index (id), not the name (title or comment).

Example: NsisIIS::ListWebSites

NsisIIS::CreateWebSite

Creates a website getting its Name (Title), Physical Path, and Bindings respectively. Other optional parameters can be fed into $1 through $4. Bindings are in the format of ADSI standard: hostname:ip:port. The following line creates a website at port 8000, all headers and all assigned IPs.

Example:

 StrCpy $1 "Classic .NET AppPool"
 StrCpy $2 "rs"
 StrCpy $3 "MyWebPage.htm" ;Multiple documents must have a ", " separator.
 NsisIIS::CreateWebSite "MyWebSite" "D:\WebSite2" "*:8000:"
 pop $0

For default document, "default.asp, default.htm" will function properly but "default.asp default.htm" or "default.asp,default.htm" will not.

NsisIIS::CreateWebSite sets "ServerBindings" Metabase parameter in C++, which accepts string format as "IP:Port:Hostname" (Microsoft Metabase Property ref.). Latest NsisIIS code(v2.0.1) has a bug to skip 1st character if no comma(,) is found. So we must pass "*" or " " in beginning of string to make it work.

NsisIIS::DeleteWebSite

Deletes a website by getting its 1 based index (id).

Example:

 NsisIIS::DeleteWebSite "2"
 pop $0

NsisIIS::GetWebSite

Gets a website information by getting its index (id). Result can be accessed via $0 through $5.

Example: NsisIIS::GetWebSite "2"

NsisIIS::ListAppPools

Lists all available IIS Application Pools as comma separated list of their names in $1.

Example: NsisIIS::ListAppPools

NsisIIS::CreateAppPool

Creates an Application Pool getting its name, and optionally other information through $1 to $3.

Example: NsisIIS::CreateAppPool "MyAppPool"

$1 Sets: .Net Framework Version, ex. "v2.0", "v4.0"
$2 Sets: Managed Pipeline Mode to "Classic" or "Integrated"
$3 Sets: Enable32BitApplications to "true" or "false"

For .Net Framework Version, word document example says "2", "4" which does not work. Source code (v2.0.1) sets managedRuntimeVersion property in C++,which must be in format of vX.Y http://technet.microsoft.com/en-us/library/cc754523(WS.10).aspx)

NsisIIS::DeleteAppPool

Deletes an Application Pool getting its ID.

Example: NsisIIS::DeleteAppPool "MyAppPool"

NsisIIS::GetAppPool

Tries to get an Application Pool information getting its name, and returning the result in variables $1 through $3.

Example: NsisIIS::GetAppPool "MyAppPool"

$1 Returns: ?
$2 Returns: .Net Framework Version
$3 Returns: Managed Pipeline Mode

TODO

  • Adding support for Virtual Directories inside a Web Site.
  • Adding support for managing another machine (not local) IIS.
  • Adding support for SSL & authentication settings.
  • Adding support for IIS 8

History

  • 2/24/2010 Released version 1.0.0 & used in my installer.
  • 7/21/2011 Released version 2.0.0 & used in my installer.

Alternatives

If the NsisIIS plugin lacks a capability that you need, you can always call appcmd.exe IIS administration tool directly from an install script, like so:

 ExecWait '"$WINDIR\system32\inetsrv\appcmd.exe" < arguments >'

Documentation for appcmd is available at http://technet.microsoft.com/en-us/library/cc772200%28v=ws.10%29.aspx