xp_cmdshell 操作系统命令外壳
这个过程是一个扩展存储过程,用于执行指定命令串,并作为文本行返回任何输出,
xpcmdshell 操作系统命令外壳
。语法:
xp_cmdshell command_string[,no_output]
command_string 要执行的命令串
no_output 不返回命令执行的输出
说明:
在把xp_cmdshell的执行许可权授予用户时,用户将能够在Windows NT命令
外壳执行运行SQL Server(通常是本地系统)的帐号有执行特权的任何
操作系统命令,
电脑资料
《xpcmdshell 操作系统命令外壳》(https://www.unjs.com)。例:
1、EXEC master..xp_cmdshell "dir *.exe"
返回可执行文件的列表
2、EXEC master..xp_cmdshell "copy d:\test1.jpg e:\" no_output
不返回输出
3、特别是执行
EXEC master..xp_cmdshell "net start awhost32"
EXEC master..xp_cmdshell "net stop awhost32"
可以启动和停止远程的PCAnywhere服务。对远程服务器操作很有帮助。