<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>restart app Archives - Jim Dolby</title>
	<atom:link href="https://jim.dolby.id.au/tag/restart-app/feed" rel="self" type="application/rss+xml" />
	<link>https://jim.dolby.id.au/tag/restart-app</link>
	<description>A Geek and still proud of it!</description>
	<lastBuildDate>Sat, 21 Sep 2019 13:26:38 +0000</lastBuildDate>
	<language>en-AU</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">195341223</site>	<item>
		<title>Relaunching a windows app using a batch script</title>
		<link>https://jim.dolby.id.au/tips/relaunching-a-windows-app-using-a-batch-script.html</link>
		
		<dc:creator><![CDATA[YTS_Jim]]></dc:creator>
		<pubDate>Sat, 21 Sep 2019 13:26:38 +0000</pubDate>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows Tips]]></category>
		<category><![CDATA[Batch Script]]></category>
		<category><![CDATA[restart app]]></category>
		<category><![CDATA[Windows 10]]></category>
		<guid isPermaLink="false">https://www.securetech.com.au/?p=187</guid>

					<description><![CDATA[<p>We recently had need to restart an app server exe automatically when the demonstration license it was running on caused the server to close regularly, annoying everyone trying to learn the system. We had need of a script (YAY) to check if it was running and restart it when required. Requirements: Check to see if [&#8230;]</p>
<p>The post <a href="https://jim.dolby.id.au/tips/relaunching-a-windows-app-using-a-batch-script.html">Relaunching a windows app using a batch script</a> appeared first on <a href="https://jim.dolby.id.au">Jim Dolby</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We recently had need to restart an app server exe automatically when the demonstration license it was running on caused the server to close regularly, annoying everyone trying to learn the system. We had need of a script (YAY) to check if it was running and restart it when required.</p>
<h2>Requirements:</h2>
<ol>
<li>Check to see if the app is running on start if not running, start it.</li>
<li>wait for some period of time (60 seconds)</li>
<li>Check to see if the app is running, if not running, start it</li>
</ol>
<h2>Flourishes:</h2>
<ol>
<li>Date app last restarted is displayed in title</li>
<li>ability to close script with a button press</li>
<li>ability to cancel wait time and relaunch app now</li>
<li>ability to log when app was restarted</li>
</ol>
<h2>Working on it:</h2>
<h3>checking if a process is running:</h3>
<p>It turns out that checking if a process is running is relatively easy:</p>
<p><pre>tasklist /FI "IMAGENAME eq appServer.exe" | findstr "appServer.exe"
if %ERRORLEVEL% == 1 Echo No server Process found
if %ERRORLEVEL% == 1 goto start
</pre>
<p>and of course, now you have to choose:</p>
<p><pre>choice /T 60 /D y /C YABCDEFGHIJKLMNOPQRSTUVWXZ /N &gt;NUL
if %ERRORLEVEL% == 1 goto loop</pre>
<p>now we start the exe</p>
<p><pre>start "" "C:\Program Files (x86)\AppVision 4.0\Bin\appServer.exe"</pre>
<p>Set the title</p>
<p><pre>title appServer (re)Started at %NowDate% %NowTime% (Press X to exit script before closing appServer.exe)</pre>
<h2>Pulling it all together:</h2>
<p><pre>@echo off
title appServer (re)Launching script started at %time:~0,2%_%time:~3,2%_%time:~6,2% (Press X to exit script before closing appServer.exe)
pushd "C:\Program Files (x86)\AppVision 4.0\Bin"

:loop
timeout 2 &gt;NUL
rem ping 127.0.0.1 -n 2 &gt;NUL
echo.
tasklist /FI "IMAGENAME eq appServer.exe" | findstr "appServer.exe"
if %ERRORLEVEL% == 1 Echo No server Process found
if %ERRORLEVEL% == 1 goto start
echo Server process found at %time%, waiting 60 seconds
echo.
rem timeout 60
rem ping 127.0.0.1 -n 30 &gt;NUL
choice /T 60 /D y /C YABCDEFGHIJKLMNOPQRSTUVWXZ /N &gt;NUL
rem echo %ERRORLEVEL%
if %ERRORLEVEL% == 1 goto loop
goto eof

:start
set NowTime=%time:~0,2%_%time:~3,2%_%time:~6,2%
set NowDate=%date:~10,4%_%date:~4,2%_%date:~7,2%

cls
echo starting
start "" "C:\Program Files (x86)\AppVision 4.0\Bin\appServer.exe"
title appServer (re)Started at %NowDate% %NowTime% (Press X to exit script before closing appServer.exe)
choice /T 10 /D y /C YABCDEFGHIJKLMNOPQRSTUVWXZ /N &gt;NUL
rem ping 127.0.0.1 -n 11 &gt;NUL
goto loop

:eof
popd
echo script finished due to keypress
rem pause</pre>
<p>The post <a href="https://jim.dolby.id.au/tips/relaunching-a-windows-app-using-a-batch-script.html">Relaunching a windows app using a batch script</a> appeared first on <a href="https://jim.dolby.id.au">Jim Dolby</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">187</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)

Served from: jim.dolby.id.au @ 2026-04-20 19:59:19 by W3 Total Cache
-->