<?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>Batch Script Archives - Jim Dolby</title>
	<atom:link href="https://jim.dolby.id.au/tag/batch-script/feed" rel="self" type="application/rss+xml" />
	<link>https://jim.dolby.id.au/tag/batch-script</link>
	<description>A Geek and still proud of it!</description>
	<lastBuildDate>Wed, 03 Jun 2020 08:06:09 +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>
		<item>
		<title>Pausing a Batch script</title>
		<link>https://jim.dolby.id.au/tips/pausing-a-batch-script.html</link>
		
		<dc:creator><![CDATA[YTS_Jim]]></dc:creator>
		<pubDate>Sat, 14 Sep 2019 08:39:00 +0000</pubDate>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Batch Script]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[Windows 10]]></category>
		<guid isPermaLink="false">https://www.securetech.com.au/?p=185</guid>

					<description><![CDATA[<p>Those of you that still use batch scripts (and why not … they are backwards compatible to older systems), will occasionally need to pause a script...</p>
<p>The post <a href="https://jim.dolby.id.au/tips/pausing-a-batch-script.html">Pausing a Batch script</a> appeared first on <a href="https://jim.dolby.id.au">Jim Dolby</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Those of you that still use batch scripts (and why not … they are backwards compatible to older systems), will occasionally need to pause a script to wait for something to start or finish or just because.</p>



<p>There are various different ways to accomplish this. My current favourite is:</p>



<pre class="wp-block-code"><code>choice /T 60 /D y /C YABCDEFGHIJKLMNOPQRSTUVWXZ /N >NUL</code></pre>
<p>The post <a href="https://jim.dolby.id.au/tips/pausing-a-batch-script.html">Pausing 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">185</post-id>	</item>
		<item>
		<title>Backup MYSQL databases on Windows 10 free Script</title>
		<link>https://jim.dolby.id.au/projects/opensource/backup-mysql-databases-on-windows-10.html</link>
		
		<dc:creator><![CDATA[YTS_Jim]]></dc:creator>
		<pubDate>Wed, 08 May 2019 04:47:31 +0000</pubDate>
				<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[Batch Script]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[DB]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows 10]]></category>
		<guid isPermaLink="false">https://www.securetech.com.au/?p=106</guid>

					<description><![CDATA[<p>We needed a simple way to automatically Backup MySQL on windows 10 for free. Our development and testing environments required: The convenience of backing up all DBs (such as This Script does). Ability to exclude some of the DBs in each machine. Date stamped backups, so changes are backed up each day. Free and preferably [&#8230;]</p>
<p>The post <a href="https://jim.dolby.id.au/projects/opensource/backup-mysql-databases-on-windows-10.html">Backup MYSQL databases on Windows 10 free Script</a> appeared first on <a href="https://jim.dolby.id.au">Jim Dolby</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>We needed a simple way to automatically Backup MySQL on windows 10 for free. Our development and testing environments required: </p>



<ul class="wp-block-list"><li>The convenience of backing up all DBs (such as <a href="https://www.proy.info/one-click-automatic-backup-all-your-mysql-database-in-zip-format-on-windows/">This Script</a> does).</li><li>Ability to exclude some of the DBs in each machine. </li><li>Date stamped backups, so changes are backed up each day.</li><li>Free and preferably open-source.</li><li>Easy to integrate into our existing <a href="https://www.securetech.com.au/projects/opensource/yts-backup-script.html">backup scripts</a>. </li></ul>



<p>A quick search showed up nothing. We decided to expand the above mentioned script functionality to include what we require. Provided below is the important parts of the script:</p>



<pre class="wp-block-code"><code>:: allows for skipping of particular databases
set SkipThis=0
for /d %%f in (*) do (
    set /A Counterf=!Counterf!+1
    :: remove echo here if you like
    echo processing folder "%%f"
    pushd "%~dp0"
        set Countera=0
        for %%a in (*.exclude) do (
            rem increment the counter, so we know how many files we have read.
            set /A Countera=!Countera!+1
            if %Debug% == 1 echo DEBUG - Exclude file found: "%%~na"
            if %%a == %%f.exclude set SkipThis=1
            if !SkipThis! == 1 if %Debug% == 1 echo DEBUG - Skipping Backup of "%%f"
            )
        If %Debug% == 1 echo DEBUG - !Countera! exclude files checked
    popd

    if !SkipThis! == 0 %mysqldump% --host="localhost" --user=%dbUser% --password=%dbPassword% --single-transaction --add-drop-table --databases %%f > %backupDir%\%dirName%\%%f.sql
    if !SkipThis! == 0 %zip% a -tzip %backupDir%\%dirName%\%fileSuffix%_%%f.sql.zip %backupDir%\%dirName%\%%f.sql
    if !SkipThis! == 0 set /A Counterb=!Counterb!+1

    :: make sure to set this back to normal, so we don't skip the next DB backup as well
    set SkipThis=0
)
echo DONE - !Counterf! DBs found, !Counterb! DBs backed up
</code></pre>



<p>We then just need to create some blank files with &#8220;<em>.exclude</em>&#8221; extension. The &#8220;<em>.exclude</em>&#8221; files have the same name as the DB to exclude. Example such as &#8220;<em>sys.exclude</em>&#8221; will exclude the &#8220;<em>sys</em>&#8221; DB from backups</p>



<p>Licensing is as usual, this script is <a href="https://www.securetech.com.au/projects/opensource">Open Source</a> and we provide a download for your easy of use.</p>



<h2 class="wp-block-heading">Troubleshooting</h2>



<ol class="wp-block-list"><li>If backups are not created, check all your location variables are set correctly</li></ol>



<h2 class="wp-block-heading">How to Use</h2>



<ol class="wp-block-list"><li>Download the MySQL Backup Script and extract into a suitable location.</li><li>Open up &#8220;<em>MySQLBackup.bat</em>&#8221; in <a href="https://notepad-plus-plus.org/download/all-versions.html">notepad++</a> (or similar).</li><li>You will need to change the dbUser, dbPassword, backupDir, mysqldump, mysqlDataDir and zip file/app locations on lines 4-9.</li><li>Save the file and run (you can open a command prompt by typing cmd into the title bar of explorer)</li><li>This script will now be executable. Go to your command prompt and run this to backup your databases.</li><li>If backups are not created, check all your location variables are set correctly</li></ol>


<p><!--EndFragment--></p>


<p>Next time you need to Backup MySQL on windows 10 for free, use this script to make it easy</p>
<p>The post <a href="https://jim.dolby.id.au/projects/opensource/backup-mysql-databases-on-windows-10.html">Backup MYSQL databases on Windows 10 free 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">106</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-19 22:45:53 by W3 Total Cache
-->