我试图执行xp_cmdshell
但没有成功。要执行的exe文件位于c:\program files (x86)\internet download manager\
我收到以下错误消息:
系统无法找到指定的路径
命令行是:
EXEC xp_cmdshell 'MPR01\\program files (x86)\internet download manager\idman /n
MPR01是服务器的名称。我也试过没有服务器的名称 - 并没有任何区别。
答案 0 :(得分:1)
EXEC xp_cmdshell '"\\MPR01\C$\program files (x86)\internet download manager\idman" /n';
服务器名称在开头有一个双反斜杠。 C $是系统共享。 我添加了双引号,因为路径有空格。
答案 1 :(得分:0)
首先,为了使用它,您需要配置SQL Server以获得执行Shell命令的访问权限,
---- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1;
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
然后执行你的实际命令。 (确保有正确的打开和关闭单引号)
xp_cmdshell '%windir%\system32\<Your .EXE>';
如果需要特殊权限;使用以下上下文,
EXECUTE AS LOGIN = '<other_login>' ;
GO
xp_cmdshell '%windir%\system32\<Your .EXE>';
REVERT ;
答案 2 :(得分:0)
xp_cmdshell默认处于禁用状态,因为这会带来安全风险。
EXEC sp_configure 'show advanced options', 1; GO
EXEC sp_configure 'xp_cmdshell', 1; GO
RECONFIGURE; GO
此后,您要尝试使用xp_cmdshell访问的Import文件夹上的"Everyone"
启用权限。参见here。