在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