|
这是我编写的脚本,但是不能开启和关闭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 |
|