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

-- 启用 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.");
  }
}

你可能感兴趣的:(SQL SERVER sp_configure 配置并通过 xp_cmdshell 调用控制台程序)