sql server 启用xp_cmdshell 重启pcanywhere

windows2003服务器使用pcanywhere进行远程管理,但有时pcanywhere会出问题而服务关闭,因为服务器在电信机房,以前这种问题只能请机房工作人员直接reset服务器,但这不是个好办法,直接reset断电,对数据而言,是很不安全的,不出问题则已,出问题就严重了。所以最好还是通过软件启动。
但问题是,windows无法登录,于是悖论了...
考虑到该服务器上装有ms sql server,而且启用了远程sa用户登录,于是想到了借用xp_cmdshell重新启动pcanywhere服务awhost32。
默认状态下xp_cmdshell是关闭状态的,需要通过sa帐号登录mssql,启用xp_cmdshell,以命令行形式开启awhost32服务,再关闭xp_cmdshell.
如下:

开启xp_cmdshell

EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'show advanced options', 0

开启awhost32服务

xp_cmdshell 'net start awhost32'

关闭xp_cmdshell

EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'xp_cmdshell', 0
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'show advanced options', 0

完成!

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据