I am looking to smarten up my batch file to NOT include the current database in the menu when the users decides to switch -looks a bit silly to chose something you are already using.
The script scans for text files in the workingdir path and uses them as identifiers for different configurations of the software. It replaces the standard shortcut for the software so the client can choose where they want to connect to - or carry on with the 'current' configuration.
It all does exactly as I want it's just making it a bit smarter with regards to how it appears to the customers.
Within the software to access a different database you just overwrite the workingdir contents with contents of another workingdir but with configs to point somewhere else. When you switch the current set up is backed up to a special directory of its own name, then the other is copied out of its own dir and overwrites the current working dir.
What I am after is (hopefully) some adjustments that will show the user what configuration they are using and if they decided to Switch 'NOT' see the current one as a choice.
What happens now & its fine, but it is clunky, it will tell them what database they are using
you are using Essex_Medical Database continue (1) or Switch (2)
if they switch they can choose the other option BUT still gives the choice of the current one which I think will look sloppy to the customer.
switch to Essex_Medical Database 1 switch to Newcastle Medical 2 continue (1) (2)
I had a go but my brain fogged up. I think I need a scan to identify the choices via the available text files, set up the input menu from variables and the current one in use be omitted from the input switch options, I hope that makes sense?? Here is the code...
@echo off
color 8b
mode con: cols=80 lines=30
title Multi Database Switcher
rem setting working dir variable
set progdata=C:\ProgramData\Company\WorkingDir
cd %progdata%
for /r %%a in (*.txt) do (
rem spdir 'special directory to hold client specific config file &
rem folders'
set spdir=C:\ProgramData\Company\%%~na
set current=%%~na
)
:menu
CLS
echo.
echo --------------------------------------------------
echo [1] -- Continue Using %current%'s DataBase
echo --------------------------------------------------
echo.
SET /P "Input=Continue(1)/Switch to Another Database(2):"
if '%Input%'=='1' goto continue
if '%Input%'=='2' goto menu2
goto :menu
:menu2
CLS
echo.
echo --------------------------------------------------
echo [2] -- Switch to the 'Essex_Medical' Database
echo [3] -- Switch to the 'Newcastle_Surgery' Database
echo --------------------------------------------------
ECHO.
echo Choose a number...
echo.
SET /P "Input=(2)/(3):"
if '%Input%'=='2' goto Essex_Medical
if '%Input%'=='3' goto Newcastle_Surgery
goto :menu2
:continue
start "" "C:\Temp\Shortcut.lnk" & exit
:Essex_Medical
robocopy %progdata% %spdir% /MIR >nul 2>&1 & robocopy C:\ProgramData\Company\Essex_Medical %progdata% /MIR >nul 2>&1
start "" "C:\Temp\Shortcut.lnk" & exit
:Newcastle_Surgery
robocopy %progdata% %spdir% /MIR >nul 2>&1 & robocopy C:\ProgramData\Company\Newcastle_Surgery %progdata% /MIR >nul 2>&1
start "" "C:\Temp\Shortcut.lnk" & exit
edit for clarity
software program uses a set of folders & a config file in one location c:\programdata\company\workingdir. In workingdir there are 3 or 4 subfolders & one cfg file. They contain info for the software as to what database to use.
I have a client who wants to access other databases, its easily done by over writing the contents of workingdir with a different folder set and config file (all same name etc) with different database details etc.
To facilitate switching my script uses a text file in the workingdir to identify the different databases usually other surgeries essex_surgery , newcastle_surgery so that when the user fires up the script it tells them from the workingdir you ARE using what ever the database is just from what the text file is called. They can continue or switch. When they switch the current working dir is backed up to a separate folder ready to be recalled if its needs to be switched back. Its just robocopy mirroing current to a named folder and over writing with chosen folder set.
My beef is, when you switch, the current database is choice to switch to and its looks silly, why choose something you are already using.
Perhaps if we populate with an array like this :
something like: