@echo off if "%1%"=="" goto ask set SID=%1% goto check1 :ask set /p SID=Please provide a SID: :check1 echo =============================================================================== echo CHECK1: Check if service is running for SERVICE_NAME: %SID% echo =============================================================================== @net start | findstr OracleService%SID% > nul if %ERRORLEVEL% == 2 goto trouble if %ERRORLEVEL% == 1 goto stopped if %ERRORLEVEL% == 0 goto started echo unknown status goto end :trouble echo There was a problem checking the status of OracleService%SID% goto end :started echo started goto check2 :stopped echo OracleService%SID% is not running, I'm going to start it. @net start OracleService%SID% > nul if %ERRORLEVEL% == 2 goto oradim if %ERRORLEVEL% == 0 goto check2 :oradim echo Unable to start the OracleService%SID% echo Use oradim to create a service: echo oradim -new -sid %SID% goto end :check2 echo =============================================================================== echo CHECK2: Check if ORACLE_SID is set echo =============================================================================== set | findstr ORACLE_SID > nul if %ERRORLEVEL% == 0 goto result goto setenv :setenv echo ORACLE_SID was not set, I'm setting it for you set ORACLE_SID=%SID% goto end echo goto end :help echo Usage: ora12560 SERVICE_NAME :result echo ORACLE_SID is set in this environment to %ORACLE_SID% echo =============================================================================== echo CHECK3: Check if ORACLE_SID set matches to the given SID echo =============================================================================== if "%SID%"=="%ORACLE_SID%" goto check3ok echo ORACLE_SID was set to %ORACLE_SID%, you requested %SID% echo I'm going to correct this for you echo If you receive this error in the future, the ORACLE_SID might be set: echo 1) Check (global) system variables echo 2) Check the registry setting in HKEY_LOCAL_MACHINE\software\oracle set ORACLE_SID=%SID% goto end :check3ok echo The ORACLE_SID set in the environment matches the requested SID. echo You should be able to connect and get no ORA-12560 :end echo =============================================================================== echo END of checks echo ===============================================================================