现在的位置: 首页 > 综合 > 正文

SQL SERVER sp_configure 配置并通过 xp_cmdshell 调用控制台程序

2014年01月19日 ⁄ 综合 ⁄ 共 497字 ⁄ 字号 评论关闭

-- 启用 cmdshell 权限

EXEC sp_configure 'show advanced options', 1
GO
-- 重新配置
RECONFIGURE
GO
-- 启用xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 1
GO
--重新配置
RECONFIGURE
GO

-- 启用 cmdshell 才能正常运行

exec xp_cmdshell 'java -jar "C:\HelloWorld.jar'

-- 禁止用 cmdshell 权限

EXEC sp_configure 'show advanced options', 1
GO
-- 重新配置
RECONFIGURE
GO
-- 启用xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 0
GO
--重新配置
RECONFIGURE
GO

 

// Java 代码

public class HelloWorld
{

  /**
   * @param args the command line arguments
   */
  public static void main(String[] args)
  {
    System.out.print("HelloWorld.");
  }
}

抱歉!评论已关闭.