Batch script to restart Oracle AutoVue Server

Oracle Autovue

Below batch script can be used or scheduled to clean ports & restart Autovue server windows service.
It will keep a log file Autostart.wri for the activities done during restart.

@echo off
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo $--          Script start Time:%TIME%, Date:%DATE%                          --$ >>Autostart.wri
echo $--          All Activities done by script are logged to Autostart.wri      --$ >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
@rem Set Jvue Home path to the installation folder of Jvue.(E.g: C:\\Program Files\\jVue)
@rem Preceed every folder with \\(TwoBackSlashes) instead of single \ (BackSlash)
@rem If any folder contains spaces in between names then use "DIR /X" in cmd line to see the equivalent short name for that folder. 
@rem Always avoid installing Autovue in folders which contains spaces in between(E.g: Programmme Files).

set JVUE_HOME=D:\\Softwares\\jVue

echo JVUE installation directory path set to %JVUE_HOME% >>Autostart.wri
echo. >>Autostart.wri
echo Resetting WMIC for script Run. >>Autostart.wri
rundll32 wbemupgd, RepairWMISetup
@REM cd /d %windir%\system32\wbem
@REM for %i in (*.dll) do RegSvr32 -s %i
@REM for %i in (*.exe) do %i /RegServer
echo. >>Autostart.wri

echo Dumping All Detailed Process List to Processlist.txt file.>>Autostart.wri
ping -n 3 127.0.0.1>nul
echo New ProcessList.txt file will be generated on each new run of script.>>Autostart.wri
@REM WMIC /OUTPUT:ProcessList.txt path win32_process get Caption,Processid,Commandline
WMIC /OUTPUT:ProcessList.txt PROCESS
@REM WMIC /OUTPUT:ProcessList%date:~7,2%%date:~4,2%%date:~10,4%_%time:~0,2%_%time:~3,2%.txt PROCESS

echo Dumping All Port Details List to Netstat.txt file.>>Autostart.wri
echo New Netstat.txt file will be generated on each new run of script.>>Autostart.wri
netstat -anb > Netstat.txt

ping -n 3 127.0.0.1>nul
echo. >>Autostart.wri
echo Java.exe processes running for Jvue Server: >>Autostart.wri
echo ---------------------------------------------------------------------------------->>Autostart.wri
WMIC /APPEND:Autostart.wri PROCESS WHERE(Name="java.exe" and CreationClassName="Win32_Process" and ExecutablePath="%JVUE_HOME%\\jre\\bin\\java.exe" and Description="java.exe")
echo ---------------------------------------------------------------------------------->>Autostart.wri
echo. >>Autostart.wri
ping -n 3 127.0.0.1>nul
echo Javaw.exe processes running for Jvue Server: >>Autostart.wri
echo ---------------------------------------------------------------------------------->>Autostart.wri
WMIC /APPEND:Autostart.wri PROCESS WHERE(Name="javaw.exe" and CreationClassName="Win32_Process" and ExecutablePath="%JVUE_HOME%\\jre\\bin\\javaw.exe" and Description="javaw.exe")
echo ---------------------------------------------------------------------------------->>Autostart.wri
echo. >>Autostart.wri
echo stopping JvueServer >>Autostart.wri
net stop "AutoVue Server" >>Autostart.wri
echo. >>Autostart.wri
echo Trying to kill if service is still running ... >>Autostart.wri
ping -n 3 127.0.0.1>nul
for /f "tokens=2" %%i in ('tasklist /nh /fi "imagename eq jVueServerX.exe" /fi "Services eq  AutoVue Server"') do (taskkill /F /PID %%i /T) >>Autostart.wri
@rem taskkill /F /IM "jVueServerX.exe" >>Autostart.wri

echo. >>Autostart.wri
echo Searching for any Stray Java.exe processes related to AutoVue.. >>Autostart.wri
echo Found Below Processes in Detail: >>Autostart.wri
ping -n 3 127.0.0.1>nul

WMIC /APPEND:Autostart.wri PROCESS WHERE(Name="java.exe" and CreationClassName="Win32_Process" and ExecutablePath="%JVUE_HOME%\\jre\\bin\\java.exe" and Description="java.exe") 

echo Trying to Terminate Stray Java.exe Jvue processes: >>Autostart.wri
ping -n 3 127.0.0.1>nul
WMIC /APPEND:Autostart.wri PROCESS WHERE(Name="java.exe" and CreationClassName="Win32_Process" and ExecutablePath="%JVUE_HOME%\\jre\\bin\\java.exe" and Description="java.exe") call terminate 

echo. >>Autostart.wri
echo -------------------------------------------------------------------------------- >>Autostart.wri
echo. >>Autostart.wri
echo Searching for any Stray Javaw.exe processes related to AutoVue.. >>Autostart.wri
echo Found Below processes in detail: >>Autostart.wri
ping -n 3 127.0.0.1>nul

WMIC /APPEND:Autostart.wri PROCESS WHERE(Name="javaw.exe" and CreationClassName="Win32_Process" and ExecutablePath="%JVUE_HOME%\\jre\\bin\\javaw.exe" and Description="javaw.exe") 
echo. >>Autostart.wri
echo Trying to Terminate Stray Javaw.exe Jvue Processes: >>Autostart.wri
ping -n 3 127.0.0.1>nul
WMIC /APPEND:Autostart.wri PROCESS WHERE(Name="javaw.exe" and CreationClassName="Win32_Process" and ExecutablePath="%JVUE_HOME%\\jre\\bin\\javaw.exe" and Description="javaw.exe") call terminate 

echo. >>Autostart.wri
echo -------------------------------------------------------------------------------- >>Autostart.wri
echo. >>Autostart.wri
echo Searching for individual open ports associated with AutoVue >>Autostart.wri
echo. >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 5099 port: >>Autostart.wri
netstat -anb | find "0.0.0.0:5099" | find "LISTENING" >>Autostart.wri
netstat -anb | find "0.0.0.0:5099" | find "ESTABLISHED" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 5098 port: >>Autostart.wri
netstat -anb | find "0.0.0.0:5098" | find "LISTENING" >>Autostart.wri
netstat -anb | find "0.0.0.0:5098" | find "ESTABLISHED" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 1099 port: >>Autostart.wri
netstat -anb | find "0.0.0.0:1099" | find "LISTENING" >>Autostart.wri
netstat -anb | find "0.0.0.0:1099" | find "ESTABLISHED" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 9700 port: >>Autostart.wri
netstat -anb | find "9700" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 9800 port: >>Autostart.wri
netstat -anb | find "9800" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 1100 port: >>Autostart.wri
netstat -anb | find "0.0.0.0:1100" | find "LISTENING" >>Autostart.wri
netstat -anb | find "0.0.0.0:1100" | find "ESTABLISHED" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 1101 port: >>Autostart.wri
netstat -anb | find "0.0.0.0:1101" | find "LISTENING" >>Autostart.wri
netstat -anb | find "0.0.0.0:1101" | find "ESTABLISHED" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 1102 port: >>Autostart.wri
netstat -anb | find "0.0.0.0:1102" | find "LISTENING" >>Autostart.wri
netstat -anb | find "0.0.0.0:1102" | find "ESTABLISHED" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 1103 port: >>Autostart.wri
netstat -anb | find "0.0.0.0:1103" | find "LISTENING" >>Autostart.wri
netstat -anb | find "0.0.0.0:1103" | find "ESTABLISHED" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo Search Result for 1104 port: >>Autostart.wri
netstat -anb | find "0.0.0.0:1104" | find "LISTENING" >>Autostart.wri
netstat -anb | find "0.0.0.0:1104" | find "ESTABLISHED" >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri
echo. >>Autostart.wri
echo Creating a temp file temp_pidlist.txt with all search results >>Autostart.wri

netstat -anb | find "0.0.0.0:5099" | find "LISTENING" > temp_pidlist.txt
netstat -anb | find "0.0.0.0:5099" | find "ESTABLISHED" >> temp_pidlist.txt
netstat -anb | find "0.0.0.0:5098" | find "LISTENING" >> temp_pidlist.txt
netstat -anb | find "0.0.0.0:5098" | find "ESTABLISHED" >> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1099" | find "LISTENING" >> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1099" | find "ESTABLISHED" >> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1100" | find "LISTENING">> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1100" | find "ESTABLISHED" >> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1101" | find "LISTENING">> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1101" | find "ESTABLISHED" >> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1102" | find "LISTENING">> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1102" | find "ESTABLISHED" >> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1103" | find "LISTENING">> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1103" | find "ESTABLISHED" >> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1104" | find "LISTENING">> temp_pidlist.txt
netstat -anb | find "0.0.0.0:1104" | find "ESTABLISHED" >> temp_pidlist.txt

echo All PID numbers found: >>Autostart.wri
echo. >>Autostart.wri
type temp_pidlist.txt >>Autostart.wri
echo. >>Autostart.wri

echo Executing taskkill on all open ports listed in temp_pidlist.txt temp file >>Autostart.wri
ping -n 3 127.0.0.1>nul
for /f "tokens=5" %%i in ('type temp_pidlist.txt') do (taskkill /F /PID %%i) >>Autostart.wri
echo. >>Autostart.wri
echo Delaying Batch Run for 10seconds before starting JVue Service Freshly >>Autostart.wri
ping -n 10 127.0.0.1>nul
echo Starting AutoVue Server >>Autostart.wri
net start "AutoVue Server" >>Autostart.wri
echo Deleting Temporary Files temp_pidlist.txt created by script during run >>Autostart.wri
del /F temp_pidlist.txt >>Autostart.wri


echo ------------------------------------------------------------------------------- >>Autostart.wri
echo $--          Script Finish Time:%TIME%, Date:%DATE% >>Autostart.wri        --$ >>Autostart.wri
echo ------------------------------------------------------------------------------- >>Autostart.wri

In case of any ┬ęCopyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply