Iiscnfg. vbs IIS configuration script, iiscnfg. vbsiis
Import and Export All or selected elements of the local or remote computer Internet Information Service (IIS) configuration database, or configure the entire IIS (configure the database and Architecture) copy the configuration to another computer. Iiscnfg performs the following functions:
To view the command syntax, click the following command:
Iiscnfg/export
Copy all or part of IIS configuration databases to XML files in encrypted or unencrypted format. Then, you can use an XML file to copy all or some configuration databases to other IIS configurations during the import operation.
Syntax
Iiscnfg [. vbs]/export/f [Path] FileName. xml/sp MetabasePath [/d EncryptingPassword] [/inherited] [/children] [/s Computer [/u [Domain] User [/p Password]
Parameters
/F [Path] FileName. xml
Required. Specifies the unique name and location of the exported file. This command fails if an existing file is specified or the directory in the specified path does not exist.
The file path must be a local path. If a file is exported from a remote computer, the/f parameter indicates a path on the remote computer.
/Sp MetabasePath
Required. Specifies the configuration database key to export. Enter the configuration database path to identify the selected key.
/D EncryptingPassword
Use the specified password to encrypt the exported file. You can use any string as the password.
The/d parameter can encrypt the session key and security attributes by using the specified password to create a secure export file. You must provide a password to use this file during the "import" operation.
If this parameter or password parameter is omitted, the exported file is encrypted with a blank password. In this way, only the security attribute is encrypted, and any administrator can use this exported file to import and configure the database.
/Inherited
Add the inherited attributes of the exported key to the exported file. If this parameter is not available, the exported file does not include the attributes inherited from the higher-level key.
/Children
Recursively Add the sub-Key of the specified key to the export file.
/S Computer
Run the script on the specified remote computer. Enter the computer name or IP address (without a backslash ). By default, scripts are run on the local computer.
/U [Domain] User
Run the script with the permissions of a specific user account. The account must be a member of the Administrators group on the remote computer. By default, scripts run with the permissions of the current user on the local computer.
/P Password
Specify the password of the user account specified in the/u parameter. If this parameter is ignored, the script prompts you to enter the password and hide the text you have entered.
/?
Display help at a command prompt.
Note
■ To perform this process, you must be a member of the local computer's Administrators group, or you must be granted appropriate permissions. If you add a computer to the Domain, members of the Domain Admins group may also be able to perform this process. As the best security operation, you can use the running method to execute this process.
■ Enclose the configuration database path elements with spaces in quotation marks. Only elements with spaces are included, not the entire path. For example, type "Default FTP Site"/IISAdmin, rather than "Default FTP Site/IISAdmin ".
Example
The following example shows how to use iiscnfg/export under specific circumstances.
Export website Configuration
The following command exports the configuration of the Finance website to the FinanceFinance. xml file. This command uses the/sp parameter to specify the configuration database path of the website/lm/W3SVC/2, and uses the/children parameter to export all the sub-keys configured. It also uses the/inherited parameter to include the inherited attributes in the exported file. This ensures that the website configuration retains these attributes even if they are imported to different systems.
Iiscnfg/export/f c: financefinance. xml/sp/lm/w3svc/2/children/inherited
In response, Iiscnfg. vbs displays the following successful messages:
Configuration exported from/lm/w3svc/2 to file c: financefinance. xml
The result file contains all the keys and sub-keys in the/lm/w3svc/2 path. It also includes IisInheritedProperties keys that contain values of all inherited properties.
Export the entire IIS configuration of the Local Computer
Run the following command to export the IIS configuration of the local computer to the D: IIStestConfig. xml file. It uses the/f parameter to specify the file name and location, and the/sp parameter to specify the Root Key (/) of the configuration database (/). The/children parameter recursively adds all the sub-keys of the Root Key to the export file. (If NO/children parameter exists, only the root key is exported .) Finally, the command uses the/d parameter and password to encrypt the exported file.
Iiscnfg/export/f d: iistestconfig. xml/sp // children/d p @ sswoRd61
In response, Iiscnfg. vbs displays the following successful messages:
Path/has been exported to d: iistestconfig. xml
Note that the configuration is different from the Metabase. xml file of the system even if the configuration is completely exported. The session key, access control list (ACL), and password are different.
In addition, you cannot determine whether to encrypt the exported file by checking the exported file. However, if you compare the Encrypted and unencrypted versions of the same file, you can find that the Security Attribute Value in the encrypted version has been changed. Therefore, the file cannot be used for the import command without a password.
Iiscnfg/import
Add the configuration settings of the XML configuration database export file to the configuration database of the IIS server.
Syntax
Iiscnfg [. vbs]/import/f [Path] FileName/sp SourcePath/dp DestinationPath [/d EncryptingPassword] [/children] [/inherited] [/merge] [/s Computer [/u [Domain] User [/p Password]
Parameters
/F [Path] FileName
Required. Specify the path and file name of the XML source file.
The file path must be a local path. When a file is imported to a remote computer, the/f parameter indicates a path on the remote computer.
/Sp SourcePath
Required. Specifies the location of the key being imported in the XML file. When the key appears in an XML file, enter the configuration database path. To import all the keys in the source file, enter the configuration database path of the Root Key.
/Dp DestinationPath
Required. Specifies the location where the import key is placed in the configuration database. Enter the path of the configuration database.
If the specified path already exists in the configuration database, the import key overwrites and replaces the key currently in the configuration database path without any warning.
/D EncryptingPassword
Specifies the password used to encrypt the configuration data.
This parameter is required to encrypt the configuration file. If the password for the encrypted file is not provided or an incorrect password is provided, the command fails.
/Children
Imports the sub-keys of a specified key recursively.
/Inherited
The inheritance attribute of the import key. This parameter is valid only when the source file includes an inherited attribute.
/Merge
Merge the keys in the XML file with the existing configuration database keys. If this parameter is not specified, the key in the XML file replaces the existing key in the same configuration database path.
The/merge parameter adds keys that only appear in the XML file to the configuration database, and keeps keys that are not in the XML file in the configuration database, the values in the XML file are applied when keys appear in both the XML file and the configuration database.
/S Computer
Run the script on the specified remote computer. Enter the computer name or IP address (without a backslash ). By default, scripts are run on the local computer.
/U [Domain] User
Run the script with the permissions of a specific user account. The account must be a member of the Administrators group on the remote computer. By default, scripts run with the permissions of the current user on the local computer.
/P Password
Specify the password of the user account specified in the/u parameter. If this parameter is ignored, the script prompts you to enter the password and hide the text you have entered.
/?
Display help at a command prompt.
Note
■ To perform this process, you must be a member of the local computer's Administrators group, or you must be granted appropriate permissions. If you add a computer to the Domain, members of the Domain Admins group may also be able to perform this process. As the best security operation, you can use the running method to execute this process.
■ Enclose the configuration database path elements with spaces in quotation marks. Only elements with spaces are included, not the entire path. For example, type "Default FTP Site"/IISAdmin, rather than "Default FTP Site/IISAdmin ".
■ The imported key must be of the expected type in the new location in the configuration database path. If the key is of an unexpected type, the configuration cannot run properly. For example, do not import the event Logging configuration (/LM/Logging) to the website configuration path, such as/LM/W3SVC/3.
■ Changes made using Iiscnfg. vbs take effect immediately. These changes are reflected in the MetaBase. xml file when the file is updated (every 5 seconds or every 50 changes.
Example
The following example shows how to use iiscnfg/import under specific circumstances.
Import websites from Exported Files
Run the following command to import the NewSite website configuration from the C: Config. xml file to the configuration database.
This command uses the/f parameter to specify the name and location of the source file. It uses the/sp (Source Path) parameter to specify the location of the key to be imported in the Config. xml file. In this case, the NewSite configuration is located in the/lm/w3svc/5 path of the Config. xml file. Then, it uses the/dp (target path) parameter to specify the configuration database location where the import key should be placed. In this case, you should import the NewSite configuration key to the/lm/w3svc/3 location in the configuration database. Finally, it uses the/children parameter to include the sub-Key of/lm/w3svc/5 in the import operation. If the/children parameter is not set, only the root directory of the website is imported.
Remember that there is no warning when the/import operation overwrites. If the configuration database already has a key at/lm/w3svc/3, these keys will be replaced by the import key.
Iiscnfg. vbs/import/f c: config. xml/sp/lm/w3svc/5/Root/NewSite/dp/lm/w3svc/3/children
In response, Iiscnfg. vbs displays the following successful messages:
Configuration imported from/lm/w3svc/5 in c: config. xml to/lm/w3svc/3 in the Metabase.
After using this command, the NewSite configuration will appear in the iis of the third website, and its configuration database path is/lm/W3SVC/3.
Import logging configurations to a remote computer
The following process imports the custom logging configuration in C: IISLogging. xml to the IIS configuration database of the remote computer. You can use this method or the extension of this method to spread the configuration to a group of servers.
To import logging configurations to a remote computer, perform the following two steps:
1. Copy the source file to a remote computer. (Iiscnfg. vbs does not allow remote paths in the/f parameter .)
2. Import the configuration to IIS.
The First Command copies the Iislogging. xml file to the remote server Svr126:
Copy IISLogging. xml \ Svr126c $
The second command imports Iislogging. xml to the IIS configuration of Svr126. It uses the/f parameter to identify the source file and uses the/sp parameter to specify the/LM/Logging/Custom Logging to be imported to configure the database path, use the/dp parameter to place the import key at the same location of the target configuration/LM/Logging/Custom Logging. (Enclose path elements with spaces in quotation marks .) It uses the/children parameter to import all sub-keys of the log record key.
To operate on Svr126, it uses the/s parameter to specify the remote computer, and uses the/u and/p parameters to run scripts with the user administrator account permissions on the remote computer.
Iiscnfg/import/f C: IISLogging. xml/sp "/lm/logging/custom logging"/dp "/lm/logging/custom logging"/children/s Svr126/u Svr126Administrator/p @ ssword1 #
In response, Iiscnfg. vbs displays the following successful messages:
Connecting to the server... finished. Configuration imported from/lm/logging/custom logging in file C: IISLogging. xml to/lm/logging/custom logging in the Metabase. [drinking wine online] http://blog.const.net.cn/a/615.htm, /lm/logging/custom Logging key and its sub-key are copied from the local configuration database to the configuration database of Svr126.
Merge virtual directories with websites
This example compares the Standard import operation with the import operation using the/merge parameter to clarify the working principle of the/merge parameter.
Both commands use the same import file Invest_vdir.xml to update the attributes of the website's Investments virtual directory.
The following example shows how Investments configures database keys before running any import operations. (This example is obtained from the backup copy of the configuration database created using Iisback. vbs ).
Configuration database before import
<IIsWebVirtualDir Location = "/LM/W3SVC/1509060625/root/Investments" AccessFlags = "AccessRead | AccessScript" AppFriendlyName = "Investments" AppIsolated = "2" AppRoot = "/LM/W3SVC /1509060625/Root/Investments "DirBrowseFlags =" DirBrowseShowDate | DirBrowseShowTime | DirBrowseShowSize | DirBrowseShowExtension | DirBrowseShowLongDate | EnableDefaultDoc "Path =" E: publicDownload "> </IIsWebVirtualDir> the following example shows The content of the Invest_vdir.xml file used in the import operation. (This example is created by exporting Investments to configure the database key and editing the export file .)
Note that the following attributes of the Investments key have been changed in the XML file:
■ The value of the AccessFlags attribute has been changed.
■ Added the AuthFlags attribute.
■ The DirBrowseFlags attribute is omitted.
Import File Content
<IIsWebVirtualDir Location = "/LM/W3SVC/1509060625/root/Investments" AccessFlags = "AccessRead" AuthFlags = "Authorization | AuthNTLM" AppFriendlyName = "Investments" AppIsolated = "2" AppRoot = ""/LM/W3SVC/1509060625/Root/Investments" Path = "E: publicDownload "> </IIsWebVirtualDir> command 1: Standard import
The following command imports the Invest_vdir.xml file to the configuration database without using the/merge parameter. This command instructs IIS to use the Investments key in the XML file to replace the Investments key in the configuration database.
This command uses the/f parameter to specify the import file, and uses the same configuration database path as the source path (/sp) and target path (/dp.
Iiscnfg/import/f e: iistestInvest_vdir.xml/sp/LM/W3SVC/1509060625/root/Investments/dp/LM/W3SVC/1509060625/root/Investments
With this command, the Investments key in the configuration database will be the same as the Investments key in the Invest_vdir.xml import file.
Command 2: import and merge
The following command combines the Investments key in the Invest_vdir.xml file into the configuration database. The/merge parameter indicates that IIS will add new attributes from the import file to the configuration database, so that the attributes of the configuration database that are not in the import file remain unchanged, in addition, when the attribute appears simultaneously in the import file and configuration database, the value of the imported file is applied.
This command is the same as command 1 except for the/merge parameter.
Iiscnfg/import/f e: iistestInvest_vdir.xml/sp/LM/W3SVC/1509060625/root/Investments/dp/LM/W3SVC/1509060625/root/Investments/merge
After using this command, configure the content of the Investments key in the database as a combination of its source, as shown in the following example.
Note that the following attributes of the Investments key in the configuration database have been changed:
■ The value of the AccessFlags attribute displayed in the configuration database and XML file has been changed. The values in the XML file appear in the configuration database.
■ The AuthFlags attribute is added only to the XML file.
■ The DirBrowseFlags attribute displayed only in the configuration database is not changed.
<IIsWebVirtualDir Location = "/LM/W3SVC/1509060625/root/Investments" AccessFlags = "AccessRead" AppFriendlyName = "Investments" AppIsolated = "2" AppRoot = "/LM/W3SVC/1509060625 /Root/Investments "AuthFlags =" AuthAnonymous | AuthNTLM "DirBrowseFlags =" DirBrowseShowDate | DirBrowseShowTime | DirBrowseShowSize | dependency | EnableDefaultDoc "Path =" E: publicDownload "> </IIsWebVirtualDir> iiscnfg/copy
Copy the IIS configuration database and architecture from one computer to another.
Syntax
Iiscnfg [. vbs]/copy/ts TargetComputer/tu TargetUser/tp TargetPassword [/s Computer [/u [Domain] User [/p Password]
Parameters
/Ts TargetComputer
Required. Copy the IIS configuration database to the specified computer. Enter the IP address or computer name (without a backslash ).
/Tu TargetUser
Required. Specifies the account used to connect to the target computer. Enter a User account in the format of [Domain] User. The account must be a member of the Administrators group on the target computer.
This parameter is required, even if the current user on the local computer is the administrator of the target computer.
/Tp TargetPassword
Required. The password of the account specified by the/tu parameter.
/S Computer
Copy the IIS configuration database on the specified remote computer to the target computer. This parameter runs scripts on the remote computer. Enter the remote computer name or IP address (without a backslash ). The default value is local computer.
/U [Domain] User
Run the script with the permissions of a specific user account. The default value is the current user on the local computer. This parameter is required if the current user is not the administrator of the remote computer.
/P Password
Specify the password of the user account specified in the/u parameter. If this parameter is ignored, IISCnfg prompts you to enter the password and hide the entered text.
/?
Display help at a command prompt.
Note
■ To perform this process, you must be a member of the local computer's Administrators group, or you must be granted appropriate permissions. If you add a computer to the Domain, members of the Domain Admins group may also be able to perform this process. As the best security operation, you can use the running method to execute this process.
■ By default, IISCnfg copies the configuration database of the local computer to the target computer specified by the/ts parameter. However, you can use the/s parameter to copy the configuration database of another computer to the target computer.
■ The copy operation uses IISBack. vbs to create a backup copy of the source configuration database and architecture. It then copies the backup copy file (. MDX and. SCX) to the target computer and replaces the configuration database and architecture of the target computer with the backup copy through IISBack. vbs. Although you can manually complete these operations, the IISCnfg copy operation provides a convenient way to copy IIS configurations.
■ This copy operation does not copy the server content related to the IIS configuration, such as web pages and FTP files.
■ The replication operation changes computer-specific and system-specific properties in the configuration database so that these properties are valid on the target computer. However, it does not adjust the directory or file path. In this way, the path in the configuration may be invalid on the target computer.
Example
The following example shows how to use iiscnfg/copy under specific circumstances.
Copy the IIS configuration of the Local Computer
Run the following command to copy the IIS configuration of the local computer to the SVR01 server. The command uses the/ts parameter to identify the target server. The/tu and tp parameters are used to provide the Administrator account and password of the user on the SVR01 server.
Iiscnfg/copy/ts SVR01/tu SVR01Admin06/tp P @ ssWord6
In response, Iiscnfg. vbs displays the following successful messages.
Backing up server 127.0.0.1 Backup complete. IP address 127.0.0.1 is the loopback address, which generally refers to the local computer. This address is used only when the configuration of the Local Computer is copied.
Copy the IIS configuration of a remote computer
Run the following command to copy the IIS configuration of the remote computer SRV06 to the mainbkp server. This command uses the/s command to identify the remote computer and uses the/u parameter to provide the administrator password on the SRV06 computer. It also uses the/ts parameter to identify the target server, and uses the/tu and tp parameters to provide the Administrator account and password on the MAINBKP server.
Unlike the optional/p parameter, the/tp parameter is required. If this parameter is omitted, this command fails.
Iiscnfg/copy/s SRV06/u Domain01Admin01/ts MAINBKP/tu MAINBKPAdmin01/tp P @ ssWord6
In response, Iiscnfg. vbs prompts you to enter the account password specified by the/u parameter. (It does not display the entered password characters .) After confirming the password, it will copy the configuration and display the message that the copy operation has been completed successfully.
Enter the password: Processing... Backing up server SRV06 Backup complete. iiscnfg/save
Save the IIS configuration database and architecture to the disk.
Syntax
Iiscnfg [. vbs]/save [/s Computer [/u [Domain] User [/p Password]
Parameters
/S Computer
Copy the IIS configuration database on the specified remote computer to the target computer. This parameter runs scripts on the remote computer. Enter the remote computer name or IP address (without a backslash ). The default value is local computer.
/U [Domain] User
Run the script with the permissions of a specific user account. The default value is the current user on the local computer. This parameter is required if the current user is not the administrator of the remote computer.
/P Password
Specify the password of the user account specified in the/u parameter. If this parameter is ignored, IISCnfg prompts you to enter the password and hide the entered text.
/?
Display help at a command prompt.
Note
■ To perform this process, you must be a member of the local computer's Administrators group, or you must be granted appropriate permissions. If you add a computer to the Domain, members of the Domain Admins group may also be able to perform this process. As the best security operation, you can use the running method to execute this process.
■ Any changes made to the configuration database using the script or IIS manager will be first written to the memory, and then written to the disk when the next scheduled update (which may occur in a few minutes) occurs. In this way, the administrator can modify the configuration database, and then only open metabase. xml to check whether the changes have not been reflected. The/save command in iiscnfg. vbs solves this problem by saving the changes to the disk immediately.
Example
The following example shows how to use iiscnfg/save in a specific situation.
Save the IIS configuration of the Local Computer
Run the following command to save the IIS configuration to a disk on the local computer.
Iiscnfg/save
In response, Iiscnfg. vbs displays the following successful messages.
Backup complete. Save the IIS configuration of the remote computer
Run the following command to save the IIS configuration to a disk on the local computer.
Iiscnfg/save/s SourceServer/u Administrator/p Kj30W
In response, iiscnfg. vbs displays the following messages.
Configuration saved comments
■ IISCnfg. vbs import and export all or part of the configuration information stored in the configuration database of the IIS server. The/copy operation copies the entire configuration database and architecture of the IIS server to the target computer. The/save operation copies the entire configuration database and architecture of the IIS server to the disk of the target computer.
■ Iisback. vbs is the IIS Backup management script. It also saves and restores the IIS configuration. However, Iisback. vbs backs up the entire configuration database and architecture. You cannot use it to save or restore the selected elements of the configuration.
■ The IISCnfg copy operation (/copy) replaces the IISSync. vbs and IISRepl. vbs tools previously included in Windows.
■ Iiscnfg requirements
■ The computer that sends the command must be running Windows XP or Windows Server 2003. The user must be a member of the Administrators group on the computer affected by the command.
■ The computer affected by the command must be running Windows Server 6.0 integrated with Internet Information Service (IIS) 2003.
■ The configuration database of the IIS server includes system-specific and computer-specific attributes. Do not import configurations of one IIS server to another without modification. Instead, use the IISBack. vbs or IISCnfg copy operation (/copy) to replace system-specific and computer-specific attributes so that the configuration is valid on the target computer. For information about how to import and export IIS configuration databases, search "Configure Database Import/Export" in IIS 6.0 help ". For more information about how to access IIS 6.0 help, see view Internet Information Service (IIS) 6.0 help.
■ When you connect to the IIS service on the specified computer, the Iiscfng. vbs will display the "connect to server" message. This message is displayed every time you use Iiscnfg. vbs, whether on a local computer or a remote computer.
■ Iiscnfg. vbs will provide options including the inherited attributes in the exported file. If this option is selected, Iiscnfg. vbs adds the inheritance attribute of the export key to the IIsInheritedProperties key in the export file. When importing a key from this file, you can select the inheritance attribute of the import key.
When importing inherited attributes, the import key retains the attributes inherited from the export configuration. If the Import fails, the key inherits the import configuration attributes.
■ To prevent unauthorized use of exported files, IISCnfg. vbs enables you to encrypt and export files using passwords. The password encrypts the session key, which in turn encrypts all attributes with security attributes configured.
You can read the encrypted exported file (only the session key and security attributes are encrypted) and delete the file. However, you cannot use the exported file in the/import operation unless the encrypted password is provided. In addition, you cannot delete or change the password from the exported file.
If you cannot use password encryption, the session key and security attributes are encrypted with a blank password, which prevents reading. However, any member of the Administrators group is allowed to import the exported files to the configuration database. Both IIS 5.1 and 6.0 do not support computer key encryption for exported files.
IIS does not execute the VB Script WScriptshell
Assume that your form passes the Value name On page a. After submission, the value is transferred to page B, the Value name = xxx obtained on page B is directly written in the src of <ifream> On page B as a url parameter and passed to the Framework page (<ifregam src = "xxx. jsp? Name = xxx ">). It is no longer difficult to get the url value in xxx. jsp.
The command is the same. The command can be run successfully in cmd and cannot be executed in bat.
The iiscnfg running path is not fully written. The batch processing will find and run it in the path where BAT is located. If it cannot be found, it means bad command .....
The command file that has been started by the system can be run in CMD without the full path.