Batch Over Short Cut - Part 1

There have been a lot of discussions on how you can access your build and set variables for user, project and even custom variables for client and so on. Over past blogs I have shown a lot on how these can be controlled and set using hta files, but if you're not confident at playing at that level then there is another answer over using edited shortcuts to your applications. On of these is to use a batch file, mainly because it opens up so many more options over a simple shortcut.

The first thing we need to know is how we can use the batch file to start our application. The key here is to capture where the application is installed, especially if you have a number of install locations across the business. To do this we can use a simple 'if exists' statement to find and then set the path. For this blog I'll be using and starting AECOsim. This would look like:

if exist "C:\Apps\Bentley\MS811_SS3\AECOsimBuildingDesigner V8i\AECOsimBuildingDesigner\*.*" (set aeco_path="C:\Apps\Bentley\MS811_SS3\AECOsimBuildingDesigner V8i\AECOsimBuildingDesigner\")

If there are multiple install locations then you could simply use a line for each, the batch will go through them and set the location that exists:

if exist "C:\Apps\Bentley\MS811_SS3\AECOsimBuildingDesigner V8i\AECOsimBuildingDesigner\*.*" (set aeco_path="C:\Apps\Bentley\MS811_SS3\AECOsimBuildingDesigner V8i\AECOsimBuildingDesigner\")

if exist "C:\Apps\Bentley\MS811_SS3\AECOsimBuildingDesigner V8i\AECOsimBuildingDesigner\*.*" (set aeco_path="C:\Bentley\MS811_SS3\AECOsimBuildingDesigner V8i\AECOsimBuildingDesigner\")

Now that the path is set, we can use the variable to start AECOsim. I've put this into it's own 'Start' routine as we can call this in a longer scenario as we'll see later.

:START
%aeco_path%AECOsimBuildingDesigner.exe
:END
To be honest, setting the user or project configs can be done in this start routine, but to be honest, I'm not a fan of using ucf files to set build variables and these days I don't even use project pcf files. More on this can be read from:
http://communities.bentley.com/other/old_site_member_blogs/peer_blogs/b/bear_blog/archive/2012/10/09/the-build-part-1-standard-directories.aspx
So, how can we take that custom build to use this this sort of start up application?
Easy, the key is to get our won cfg file into the 'config\appl\' directory of the installed application. The reason is that any cfg placed here will be read and used by the application. Check out the next link for more:
http://communities.bentley.com/other/old_site_member_blogs/peer_blogs/b/bear_blog/archive/2012/10/09/build-kick-off-ustn-site.aspx
So, now that we have our std_appl.cfg file, how do we get it to our install location? Mine is something like:
#---------------------------------------------------------------------------
# Set my_build drive mappings
#---------------------------------------------------------------------------

build_drv = C:/CAD_Stuff/_MyBuild/Bentley/




#---------------------------------------------------------------------------
# Determine MicroStation Version
#---------------------------------------------------------------------------
# Set Version 85 to be the default
STD_MS = MS89

%if defined (_VERSION70)
STD_MS = MS70
%endif

%if defined (_VERSION80)
STD_MS = MS85
%endif

%if defined (_VERSION_8_11)
STD_MS = MS811_SS3
%endif

#---------------------------------------------------------------------------
# Set standard configuration based upon MicroStation version
#---------------------------------------------------------------------------

%if exists ($(build_drv)Standard/$(STD_MS)/Standards/.)
_USTN_SITE = $(build_drv)Standard/$(STD_MS)/Standards/
%endif
Well, firstly we set the location of our build directory where the file is kept:
set cfg_path=C:\CAD_Stuff\_MyBuild\Bentley\Standard\MS811_SS3\Standards\data\
We then create a new routine to run an 'xcopy' command that will copy the file to the 'config\appl'
:appl_copy
xcopy %cfg_path%*.cfg %aeco_path%config\appl\ /e /h /s /r /k /y
:appl_copyend
Check out Google for more information on xcopy switches.
We're now ready to go, and while this is simply a start point, for those of you in a small firm or on your own it's a great way to start to build some value adding into firing off your application.
More soon.
Anonymous