在windows系统下使用批处理文件可以帮我们解决很多繁琐操作,本文介绍个WINDOWS系统下用.bat文件启动oracle服务的方法。
把以下横线间的代码,保存成.bat文件,双击即可~红色为服务名,可以自己修改~
--------------------------------------------
@echo off
color 0B
::判断服务是否被禁用,如果被禁用就设置为自动
::wmic service where "name="OracleXETNSListener" and startmode="disabled"" call changestartmode
::wmic service where "name="OracleServiceXE" and startmode="disabled"" call changestartmode
::判断服务是否启动,如果未启动就启动此服务
::wmic service where "name="OracleXETNSListener" and state="stopped"" call startservice
::wmic service where "name="OracleServiceXE" 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 OracleXETNSListener
net start OracleServiceXE
goto success
:stop
net stop OracleXETNSListener
net stop OracleServiceXE
goto end
:success
::net start
@echo 服务开启成功,按任意键结束!
:end
del "service.txt"
@pause>nul
--------------------------------------------