Autoit开启和关闭Oracle服务 问题
这是我编写的脚本,但是不能开启和关闭Oracle服务,请大家看一下是什么原因? 我的电脑是win7#include<ServiceControl.au3>
#include <GUIConstantsEx.au3>
OracleServiceColltor()
Func OracleServiceColltor()
Local $Button_start, $Button_stop, $event_msg,$Lable_msg
GUICreate("OracleServiceColltor")
Opt("GUICoordMode", 0)
$Button_start = GUICtrlCreateButton("开启服务", 50, 30, 100)
$Button_stop = GUICtrlCreateButton("关闭服务", 200,0,100)
$Lable_msg = GUICtrlCreateEdit(getOracleServiceState(),-230,40,360,200)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_start
StartOracleService()
Case $msg = $Button_stop
StopOracleService()
EndSelect
WEnd
EndFunc
Func StartOracleService()
If _ServiceRunning("","OracleServiceORCL") <> 1 Then
_StartService("","OracleServiceORCL")
EndIf
If _ServiceRunning("","OracleOraDb11g_home1TNSListener") <> 1 Then
_StartService("","OracleOraDb11g_home1TNSListener")
EndIf
If _ServiceRunning("","OracleMTSRecoveryService") <> 1 Then
_StartService("","OracleMTSRecoveryService")
EndIf
EndFunc
Func StopOracleService()
If _ServiceRunning("","OracleServiceORCL") = 1 Then
_StopService("","OracleServiceORCL")
EndIf
If _ServiceRunning("","OracleOraDb11g_home1TNSListener") = 1 Then
_StopService("","OracleOraDb11g_home1TNSListener")
EndIf
If _ServiceRunning("","OracleMTSRecoveryService") = 1 Then
_StopService("","OracleMTSRecoveryService")
EndIf
EndFunc
Func getOracleServiceState()
Local $State
If _ServiceRunning("","OracleServiceORCL") <> 1 Then
$State= "OracleServiceORCL stop" & @CRLF
Else
$State ="OracleServiceORCL start" & @CRLF
EndIf
If _ServiceRunning("","OracleOraDb11g_home1TNSListener") <> 1 Then
$State = $State & "OracleOraDb11g_home1TNSListener stop" & @CRLF
Else
$State = $State & "OracleOraDb11g_home1TNSListener start" & @CRLF
EndIf
If _ServiceRunning("","OracleMTSRecoveryService") <> 1 Then
$State = $State & "OracleMTSRecoveryService stop" & @CRLF
Else
$State = $State & "OracleMTSRecoveryService start" & @CRLF
EndIf
Return $state
EndFunc 类似的程序?
回复 2# 虫子樱桃
对,请问这个程序如何实现的呢?可以给我参考吗?不胜感激。 回复 3# dominge
主要就是一个查询服务状态的函数,不过内容需要自己修改下!
回复 4# 虫子樱桃
谢谢啦很有帮助我找到上午的原因了是因为没有用管理员运行所以没有权限去修改服务的状态谢谢你的帮助我会好好学习你的代码的 我也顺便下那个UDF来学学 Windows Services UDF.7z 有这UDF例子么? 也许是虫子樱桃兄写的
页:
[1]