在Windows系統下使用批處理文件可以幫我們解決很多繁瑣操作,本文介紹個Windows系統下用.bat文件啟動Oracle服務的方法。
以下,保存成.bat文件,雙擊即可~紅色為服務名,可以自己修改~
--------------------------------------------
@echo off
color 0B
::判斷服務是否被禁用,如果被禁用就設置為自動
::wmic service where "name="OracleOraDb10g_home1TNSListener" and startmode="disabled"" call changestartmode
::wmic service where "name="OracleServiceORCL" and startmode="disabled"" call changestartmode
::判斷服務是否啟動,如果未啟動就啟動此服務
::wmic service where "name="OracleOraDb10g_home1TNSListener" and state="stopped"" call startservice
::wmic service where "name="OracleServiceORCL" and state="stopped"" call startservice
net start >service.txt
find /i service.txt "Oracle_10G"
if errorlevel 1 goto start
if errorlevel 0 goto stop
:start
net start OracleOraDb10g_home1TNSListener
net start OracleServiceORCL
goto success
:stop
net stop OracleOraDb10g_home1TNSListener
net stop OracleServiceORCL
goto end
:success
::net start
@echo 服務開啟成功,按任意鍵結束!
:end
del "service.txt"
@pause>nul