473,739 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Executing MSACCESS.EXE without a full path?

I've got a .BAT file that I use for executing various MS Access apps that I
wrote way back in the days of 2.0.

It's evolved over time, but it still contains a number of possible paths to
MSACCESS.EXE, tries them all, takes the first one it finds, and dies if none is
found.

Seems to me like at some time or another I was able to clone this .BAT file and
implement it with no path. Something about MSACCESS being a registered
application.

I'd like to do that now, but find that just typing MSACCESS.EXE on the command
line doesn't work....so maybe I rememeber wrong....

My agenda is to bulletproof this .BAT file a little more so it isn't dependent
on a list of paths.

Suggestions?
------------------------------------------
For the maschoistically-inclined, here's a copy of the file.
Actually, it's three files: A small "root" .BAT file, a .TXT
file that the root copies into a .BAT file, and a "Version" file
that specifiesd the latest-and-greatest version of the app.

Trets_Go1.bat:
----------------------------------------
@ECHO OFF
SET AppDirLAN=\\xxx \yyy\zzz\TRETS
SET AppDirLocal=C:\ Temp

COPY "%AppDirLan%\Ba t\Trets_Go_2.tx t" "%AppDirLocal%\ Trets_Go_2.bat"
CALL "%AppDirLocal%\ Trets_Go_2.bat"
----------------------------------------
Version.txt:
----------------------------------------
:* --------------------------
:* This file is used by the 2 Trets_Go Bat files
:* to decide which version to execute and, if necessary,
:* copy down to the user's C: drive.
:*
:* The "...Refresh " parameters enable us
:* to force a re-copy of an application down
:* to each user's C: drive. Useful if a user's
:* copy of the app becomes corrupted and we do
:* not want to elevate a new version.
:*
:* Needless to say, it should be set back to "NO"
:* once the user in question has invoked the app.
SET AppVersion=019
SET AppRefresh=No
SET BatRefresh=No
----------------------------------------

Trets_Go2.txt:
----------------------------------------
@ECHO OFF
:* (Please refer to end of file for explainatory remarks)
:* ------------------------------
:* Capture script name/path into memory variables
:* Technically, this may seem redundant, but it makes
:* for a little lesss gobbeldygook in the code when we
:* want to refer to these values

SET ScriptName=%~n0
SET ScriptPath=%~f0
:* ------------------------------
:* If user asked for help, display help
:*
IF /i {%1}=={/Help} (call :Help %2) & (GOTO :ExitNormal)
IF /i {%1}=={/?} (call :Help %2) & (GOTO :ExitNormal)
IF /i {%1}=={?} (call :Help %2) & (GOTO :ExitNormal)

:* -----------------------------Begin Main Procedure ----------------------------------------
:Main

ECHO .
ECHO . --------------------------------
ECHO . Setting common variables...
ECHO .
CALL :setCommon

ECHO .
ECHO . --------------------------------
ECHO . Setting TRETS-specific memory variables
ECHO . (AppDirLocal and AppDirLan set in Trets_Go_1)
SET AppName=TretsAp p
SET AppDescr=TRETS

SET IniPath=%AppDir LAN%\Bat\TRETS. ini
SET SecPath=%AppDir LAN%\Bat\SYSTEM .MDW
SET VerPath=%AppDir Lan%\Bat\Versio ns.txt

TITLE %AppName%

ECHO .
ECHO . --------------------------------
ECHO . Verifying/creating local directory
ECHO .

IF NOT EXIST %AppDirLocal% MD %AppDirLocal%

ECHO .
ECHO . --------------------------------
ECHO . Checking for version file...
ECHO .
IF NOT EXIST %VerPath% GOTO
AbendVersionTxt Missing
:VerCopy
:* ----------------
:* Copy Versions.TXT file to .BAT and then execute it to set memory
:* variables containing latest version number for each app and whether-or-not
:* we want to force a refresh of existing app
:*
ECHO .
ECHO . --------------------------------
ECHO . Getting version numbers...
ECHO .
COPY "%VerPath%"
%AppDirLocal%\T rets_Version_Se t.BAT
CALL %AppDirLocal%\T rets_Version_Se t.BAT
:BatCheck
:* ----------------
:* Check for existing .BAT file in AppDirLocal
:* No sense copying it down again if it already exists...
:*
:* To make things more bulltproof, we may want to force
:* a copy anyhow by setting "BatRefresh=Yes ".
:*

ECHO .
ECHO . -----------------------
ECHO . Checking latest version of .BAT file on your PC...
ECHO .
IF NOT EXIST "%AppDirLocal%\ Trets_Go_2.%Bat Version%.bat" GOTO BatCopy
IF %BatRefresh%==Y ES GOTO BatCopy
IF %BatRefresh%==Y es GOTO BatCopy
IF %BatRefresh%==y es GOTO BatCopy
GOTO EOF
:BatCopy
:* ----------------
:* Copy the .BAT file down to user's C: drive
:*
IF NOT EXIST %AppDirLAN%\Bat \Trets_Go_2.txt GOTO AbendBatMissing
DEL %AppDirLocal%\T rets_Go.*.bat
ECHO .
ECHO . -----------------------
ECHO . Copying "%AppDirLAN%\Ba t\Trets_Go_2.tx t" down to
"%AppDirLocal%\ Trets_Go.%AppVe rsion%.bat"....
ECHO .
COPY "%AppDirLAN%\Ba t\Trets_Go_2.tx t"
"%AppDirLocal%\ Trets_Go.%BatVe rsion%.bat"

:* ----------------
:* Check for existance of MS Access'
:* .EXE in various and sundry locations
:*
:* We don't validate the entire directory.
:* As long as MSACCESS.EXE is there, we
:* assume everything else is OK.
:*
:AccCheck
ECHO .
ECHO . -----------------------
ECHO . Looking for a copy of MS Access...
ECHO .

set AccessPath=%Acc essPath1%
IF EXIST "%AccessPat h%" GOTO AppCheck

set AccessPath=%Acc essPath2%
IF EXIST "%AccessPat h%" GOTO AppCheck

set AccessPath=%Acc essPath3%
IF EXIST "%AccessPat h%" GOTO AppCheck

set AccessPath=%Acc essPath4%
IF EXIST "%AccessPat h%" GOTO AppCheck
GOTO AbendAccessMiss ing
:AppCheck
:* ----------------
:* Check for existing app version on C:
:* No sense copying it down again if it already exists...
:*
:* To make things more bulltproof, we may want to force
:* a copy anyhow by setting "AppRefresh=Yes ".
:*

ECHO .
ECHO . -----------------------
ECHO . Checking latest version of application on your PC...
ECHO .

IF NOT EXIST %AppDirLocal%\% AppName%.%AppVe rsion%.mdb GOTO AppCopy
IF %AppRefresh%==Y ES GOTO AppCopy
IF %AppRefresh%==Y es GOTO AppCopy
IF %AppRefresh%==y es GOTO AppCopy
GOTO AppStart
:AppCopy
:* ----------------
:* Copy the app down to user's C: drive
:*
IF NOT EXIST %AppDirLAN%\%Ap pName%.%AppVers ion%.mdb GOTO AbendAppMissing
DEL %AppDirLocal%\% AppName%.*.mdb
ECHO .
ECHO . -----------------------
ECHO . Copying new version of application down to your PC....
ECHO .
XCOPY "%AppDirLAN%\%A ppName%.%AppVer sion%.mdb" %AppDirLocal%\ /K
:AppStart
ECHO .
ECHO . -----------------------
ECHO . Starting MS Access...
ECHO .

START /B /HIGH /MAX "FIMMA Startup" "%AccessPat h%"
%AppDirLocal%\% AppName%.%AppVe rsion%.mdb /ini "%IniPath%" /wrkgrp "%SecPath%"
/Excl

SET RET=0
GOTO :EOF
:* -----------------------------End Main Procedure ----------------------------------------

:setCommon
:* ----------------
:* Specify up to four alternatives for
:* finding standalone MS Access, ranked
:* by search order: first one found is the
:* one that's used.
:*
:* NB: Any required quotes get added when we do the "START" command

SET AccessPath1=C:\ Program Files\Microsoft Office 2000\Office\MSA CCESS.EXE
SET AccessPath2=c:\ program files\microsoft office\office\m saccess.exe

SET AccessPath3=C:\ Microsoft Office\Office\M SACCESS.EXE
SET AccessPath4=E:\ Program Files\Office.2K \Office\MSACCES S.EXE
GOTO :EOF
:Help
:* This routine is redundant since we have no parms that need to be supplied
:* on the command line. We left it in in case we add parms some day.

ECHO .
ECHO .
ECHO . ----------------------------------------
ECHO .
IF NOT "%BadParam%"==" " COLOR E0 & ECHO . Uh-Oh! Bad or missing parameter.
ECHO .
ECHO . The syntax of this command should be:
ECHO .
ECHO . "Trets_Go_2 "
ECHO .
ECHO . ----------------------------------------
ECHO .
PAUSE
GOTO :EOF
:AbendAccessMis sing
ECHO OFF
COLOR E0
ECHO .----------- Cannot Run %AppDescr%
ECHO .
ECHO . Could not find MS Access in any of these paths:
ECHO .
ECHO . %AccessPath1%
ECHO . %AccessPath2%
ECHO . %AccessPath3%
ECHO . %AccessPath4%
ECHO .
ECHO . Please notify supervisor or LAN manager.
ECHO .
ECHO . %ScriptPath\%Sc riptName%
ECHO .--------------------------------------------
PAUSE
GOTO :ExitNormal

:AbendAppMissin g
COLOR E0
ECHO .----------- Cannot Run %AppDescr%
ECHO .
ECHO . %AppDirLAN%\%Ap pName%.%AppVers ion%.mdb not found.
ECHO .
ECHO . Please notify supervisor or LAN manager.
ECHO .
ECHO . %ScriptPath\%Sc riptName%
ECHO .--------------------------------------------
PAUSE
GOTO :ExitNormal
:AbendBatMissin g
COLOR E0
ECHO .----------- Cannot Run %AppDescr%
ECHO .
ECHO . %AppDirLAN%\Bat \Trets_Go_2.txt not found.
ECHO .
ECHO . Please notify supervisor or LAN manager.
ECHO .
ECHO . %ScriptPath\%Sc riptName%
ECHO .--------------------------------------------
PAUSE
GOTO :ExitNormal
:AbendVersionTx tMissing
ECHO OFF
COLOR E0
ECHO .----------- Cannot Run %AppDescr%
ECHO .
ECHO . %VerPath% not found.
ECHO .
ECHO . Please notify supervisor or LAN manager.
ECHO .
ECHO .
ECHO . %ScriptPath\%Sc riptName%
ECHO .--------------------------------------------
PAUSE
GOTO :ExitNormal
:ExitNormal
GOTO :EOF

:* =============== =============== =============== =============== =============== ==
:* (these remarks are so lengthy that they were actually slowing down the execution
:* when they were up in the beginning of the file - so we moved them here)
:*
:* PURPOSE: To download the latest version of one of several applications
:* and start it up under MS Access.
:* ACCEPTS: (nothing)
:* NEEDS: - A text file named 'Versions.txt'. Refer to the 'VerPath'
:* parameter below. A sample file is appended in remarks at the end
:* of this .BAT file.
:*
:* NOTES: 0) Remarks slow execution too much when a .BAT file is run over the LAN.
:* Therefore we have a little root .BAT file on the lan ("Trets_Go_1.ba t")
:* that copies this .TXT file down to C:\TEMP and renames it to .BAT.
:* This speeds up execution a *LOT*.
:*
:* 1) This is all dependent upon a three-level naming convention for your app
:* that begins with the app name, includes a three-digit version number,
:* and ends with ".MDB".
:* e.g. TimeTrackerApp. 016.mdb would be version 0.16 of the Time Tracker application.
:*
:* 2) This is intended to be called from a shortcut with a command line that
:* reads something like: D:\TimeTracker\ Bat\AccessApp.b at TimeTracker
:*
:* 3) Quite a few memory variables are set within this procedure.
:* If you create an NT 3.51 shortcut, make sure it's "Environmen t"
:* is maxed at 4096 or this procedure may run out of environment
:* space and die.
:*
:* 4) Memory variables that you need to peruse and set when customizing
:* this procedure for a given LAN situation are:
:*
:*
:* IniPath - The full DOS path or UNC to the .INI file used by the application
:* This is the one we put on the Access command line.
:* NB: Each app should try to use the same .INI file, but we do it
:* this way in case somebody wants their very own....
:* SecPath - The full DOS path or UNC to the .MDA file we use for security
:* VerPath - The full DOS path or UNC to the little .TXT file that contains
:* latest version number of each app.
:* AccessPath1 - A full DOS path or UNC to someplace where we can find
:* a complete install of MS Access 8.0
:* AccessPath2, 3, 4 - Ditto AccessPath1. This means that different users
:* can have different installs of Access as long as each is
:* represented here
:*
:* Scroll down to procedure ":setCommon " to see these variables.
:*
:* 6) Memory variables that need to be set for each application are:
:*
:* AppName - The name of the application as it appears in the .mdb file name.
:* SB exactly the same as the parameter for that app.
:* AppDescr - User friendly short description for error messages
:* AppVersion - The version of the application. Set from the .TXT file.
:* AppRefresh - Whether-or-not we want to force-feed a new copy of the app
:* to the user's C: drive even though one is already there.
:* AppDirLAN - The DOS path or UNC that points to the directory where
:*
:* Scroll down to a given applications ":set[AppName]" procedure to see
:* these variables.
:*
:* 7) Last, but not least, is the "Version File" - currently named "Versions.t xt".
:* It loads two variables for each application:
:* ....Version (e.g. "TimeTrackerVer sion", "FimmaVersi on") which tells what version of the app to run
:* ....Refresh (e.g. "TimeTracke r", "FimmaRefre sh") which tells whether-or-not
:* we want to download the app even though it is already on the user's PC
:*
:* =============== =============== =============== =============== =============== ==

----------------------------------------
--
PeteCresswell
Nov 12 '05 #1
15 11551
RE/
Suggestions?


Got it!

The magic word, in this case, is "START".

e.g.

C:\ START MSACCESS
--
PeteCresswell
Nov 12 '05 #2
x@y.z ((Pete Cresswell)) wrote in
<g3************ *************** *****@4ax.com>:
RE/
Suggestions ?


Got it!

The magic word, in this case, is "START".

e.g.

C:\ START MSACCESS


And that doesn't work on all installations of Windows.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #3
On Fri, 21 Nov 2003 00:52:17 GMT, "(Pete Cresswell)" <x@y.z> wrote:

Other suggestion: step into the 21st century and use a shell script
file. You can write it in VBScript, execute it using the Windows
Script Host (wscript.exe). Now you can use CreateObject to create an
MsAccess object.

-Tom.

I've got a .BAT file that I use for executing various MS Access apps that I
wrote way back in the days of 2.0.

It's evolved over time, but it still contains a number of possible paths to
MSACCESS.EXE , tries them all, takes the first one it finds, and dies if none is
found.

Seems to me like at some time or another I was able to clone this .BAT file and
implement it with no path. Something about MSACCESS being a registered
application.

I'd like to do that now, but find that just typing MSACCESS.EXE on the command
line doesn't work....so maybe I rememeber wrong....

My agenda is to bulletproof this .BAT file a little more so it isn't dependent
on a list of paths.

Suggestions?

<clip>

Nov 12 '05 #4
to*****@no.spam .cox.net (Tom van Stiphout) wrote in
<5d************ *************** *****@4ax.com>:
Other suggestion: step into the 21st century and use a shell
script file. You can write it in VBScript, execute it using the
Windows Script Host (wscript.exe). Now you can use CreateObject to
create an MsAccess object.


You can't count on the WSH being available, as it is so
horrendously insecure that wise system adminstrators completely
remove it from client PCs.

It's too bad Microsoft wasn't thinking about security when they
created the WSH.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #5
dX********@bway .net.invalid (David W. Fenton) wrote in
news:94******** *************** ****@24.168.128 .86:
to*****@no.spam .cox.net (Tom van Stiphout) wrote in
<5d*********** *************** ******@4ax.com> :
Other suggestion: step into the 21st century and use a shell
script file. You can write it in VBScript, execute it using the
Windows Script Host (wscript.exe). Now you can use CreateObject to
create an MsAccess object.


You can't count on the WSH being available, as it is so
horrendously insecure that wise system adminstrators completely
remove it from client PCs.

It's too bad Microsoft wasn't thinking about security when they
created the WSH.


David is right; all code, scripts, and executabulls are horrendously
insecure and should be expunged from every PC.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #6
> David is right; all code, scripts, and executabulls are horrendously
insecure and should be expunged from every PC.


I think David is right indeed!
Never heard of vbs-virusses and the like?

Every nitwit can create extremely dangerous vbs-scripts (WSH is powerful).
Without any other program needed (just hit Enter) such a script can destroy your data completely.
I know some system adminstrators that actually remove WSH from their PC's.
I heard some others who rename the executable in order to prevent disasters.

Arno R


Nov 12 '05 #7
"Arno R" <ar************ ****@tiscali.nl > wrote in news:3fbe30e6$0 $36112
$5******@dreade r2.news.tiscali .nl:
David is right; all code, scripts, and executabulls are horrendously
insecure and should be expunged from every PC.
I think David is right indeed!


Then we agree, I think.
Never heard of vbs-virusses and the like?
Gee, who could remember something like that?
Every nitwit can create extremely dangerous vbs-scripts ...


I will yield to your superior knowledge of the capability of nitwits.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #8
RE/

And that doesn't work on all installations of Windows.


Am I OK banking on it working with all installs of Win 2000 Pro?

--
PeteCresswell
Nov 12 '05 #9
RE/
Other suggestion: step into the 21st century and use a shell script
file. You can write it in VBScript, execute it using the Windows
Script Host (wscript.exe). Now you can use CreateObject to create an
MsAccess object.


What advangages would that have over a .BAT file? (if it's interactvely
debuggable, that would be one...)
--
PeteCresswell
Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2259
by: rvdw | last post by:
Hi All, I've a serious problem with executing stored procedures (SQL2000) from an Access db (version 97). After executing a stored procedure , msaccess hangs. The whole call to the procedure is running fine, but immediatly after this msaccess hangs, when the focus goes back to the calling form ? Has anyone any idea what i can test or look at. Thanks a lot !!!!!!
13
2281
by: Darren Dale | last post by:
Some time ago I asked about executing a python program or script. For windows, I was informed that the .py extension could be added to some list of executable extensions, and then I could just type "mycode" instead of "python mycode.py". Great advice, worked like a charm. I recently jumped ship, and have been running Gentoo Linux for about two months. Is it possible to get the same behavior on Linux? I thought it would have something to...
0
1960
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is inside a package, the invocation will fail with a "Module not found" error. This PEP is aimed at fixing that :) Cheers, Nick.
15
2609
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that for Python 2.5. Previously, posting of a draft version of the PEP to python-dev and python-list didn't actually generate any responses. I'm not sure if that's an indication that people don't see the restriction to top-level modules as a problem...
1
3151
by: rvdw | last post by:
Hi All, I've a serious problem with executing stored procedures (SQL2000) from an Access db (version 97). After executing a stored procedure , msaccess hangs. The whole call to the procedure is running fine, but immediatly after this msaccess hangs, when the focus goes back to the calling form ? Has anyone any idea what i can test or look at. Thanks a lot !!!!!!
2
18605
by: GGerard | last post by:
Hello I would like to be able to retrieve the path of the MSAccess.exe file through code. Using (Application.CurrentProject.BaseConnectionString) : I can retrieve the path of the workgroup and the mdb file. Using (Application.DBEngine.IniPath) : I can retrieve what seems to be the Windows Registry Key path for the
2
1786
by: reidarT | last post by:
I am making an installation program for an Access application. The application is run on both Office 2000, 2002, 2003 and soon 2007 versions of Office, When I install the application I need a shortcut from the users desktop and I need C:\programfiles\office\office9\msaccess path\application.mdb /wrkgrp path\lockfile.mdw C:\programfiles\office\office10\msaccess path\application.mdb /wrkgrp path\lockfile.mdw...
0
2023
by: bbrewder | last post by:
I am struggling with some MSAccess automation issues. Basically, we have a .Net application that uses MSAccess for reporting (legacy code). We are able to launch MSAccess fine and even work with the MSAccess COM objects to run our reports (using GetObject(<MDB Path>) - see http://support.microsoft.com/default.aspx?scid=kb;en-us;317113&Product=vbNET for info on how to do this). The problem that we are running into is that if our Access...
7
10079
by: chage | last post by:
Hi, I have been searching around to try adding reference assembly to another assembly during runtime, programatically. Is this possible in .Net? The reason for this is because i am having trouble using a library that creates an instance of a Type that i specified, and it failed the locate the Type during runtime, if i do not reference it during compile time.
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8794
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9483
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9211
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8216
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4572
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.