|
1 | 1 | --- |
2 | | -title: "xp_cmdshell Server Configuration Option | Microsoft Docs" |
3 | | -ms.custom: "" |
4 | | -ms.date: "03/02/2017" |
| 2 | +title: xp_cmdshell Server configuration option |
5 | 3 | ms.prod: sql |
6 | 4 | ms.prod_service: high-availability |
7 | 5 | ms.reviewer: "" |
8 | 6 | ms.technology: configuration |
9 | 7 | ms.topic: conceptual |
10 | | -dev_langs: |
11 | | - - "TSQL" |
12 | | -helpviewer_keywords: |
13 | | - - "xp_cmdshell" |
| 8 | +dev_langs: "TSQL" |
| 9 | +helpviewer_keywords: "xp_cmdshell" |
14 | 10 | ms.assetid: c147c9e1-b81d-49c8-b800-3019f4d86a13 |
15 | 11 | author: markingmyname |
16 | 12 | ms.author: maghan |
| 13 | +ms.custom: contperfq4 |
| 14 | +ms.date: 06/12/2020 |
17 | 15 | --- |
18 | | -# xp_cmdshell Server Configuration Option |
| 16 | + |
| 17 | +# xp_cmdshell Server configuration option |
| 18 | + |
19 | 19 | [!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md](../../includes/appliesto-ss-xxxx-xxxx-xxx-md.md)] |
20 | 20 |
|
21 | | - The **xp_cmdshell** option is a [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] server configuration option that enables system administrators to control whether the **xp_cmdshell** extended stored procedure can be executed on a system. By default, the **xp_cmdshell** option is disabled on new installations. Before enabling this option, it is important to consider the potential security implications associated with the use of this option. Newly-developed code should not use this option as it should generally be left disabled. Some legacy applications require it to be enabled, and if they cannot be modified to avoid the use of this option, it can be enabled by using the Policy-Based Management or by running the **sp_configure** system stored procedure as shown in the following code example: |
| 21 | +This article describes how to enable the **xp_cmdshell** SQL Server configuration option. This option allows system administrators to control whether the [xp_cmdshell extended stored procedure](../../relational-databases/system-stored-procedures/xp-cmdshell-transact-sql.md) can be executed on a system. By default, the **xp_cmdshell** option is disabled on new installations. |
| 22 | + |
| 23 | +Before enabling this option, it's important to consider the potential security implications. |
| 24 | + |
| 25 | +- Newly developed code shouldn't use the **xp_cmdshell** stored procedure and generally it should be left disabled. |
| 26 | +- Some legacy applications require **xp_cmdshell** to be enabled. If they can't be modified to avoid the use of this stored procedure, you can enable it as described below. |
| 27 | + |
| 28 | +If you need to enable **xp_cmdshell**, you can use [Policy-Based Management](../../relational-databases/policy-based-management/administer-servers-by-using-policy-based-management.md) or run the **sp_configure** system stored procedure as shown in the following code example: |
22 | 29 |
|
23 | | -``` |
| 30 | +``` sql |
24 | 31 | -- To allow advanced options to be changed. |
25 | | -EXEC sp_configure 'show advanced options', 1; |
| 32 | +EXECUTE sp_configure 'show advanced options', 1; |
26 | 33 | GO |
27 | 34 | -- To update the currently configured value for advanced options. |
28 | 35 | RECONFIGURE; |
29 | 36 | GO |
30 | 37 | -- To enable the feature. |
31 | | -EXEC sp_configure 'xp_cmdshell', 1; |
| 38 | +EXECUTE sp_configure 'xp_cmdshell', 1; |
32 | 39 | GO |
33 | 40 | -- To update the currently configured value for this feature. |
34 | 41 | RECONFIGURE; |
35 | 42 | GO |
36 | 43 | ``` |
37 | 44 |
|
38 | | -## See Also |
39 | | - [Server Configuration Options (SQL Server)](../../database-engine/configure-windows/server-configuration-options-sql-server.md) |
40 | | - [Administer Servers by Using Policy-Based Management](../../relational-databases/policy-based-management/administer-servers-by-using-policy-based-management.md) |
41 | | - |
42 | | - |
| 45 | +## Next steps |
| 46 | + |
| 47 | +- [xp_cmdshell extended stored procedure](../../relational-databases/system-stored-procedures/xp-cmdshell-transact-sql.md) |
| 48 | +- [Server Configuration Options (SQL Server)](server-configuration-options-sql-server.md) |
| 49 | +- [Administer Servers by Using Policy-Based Management](../../relational-databases/policy-based-management/administer-servers-by-using-policy-based-management.md) |
0 commit comments