0

I need to be able to run a batch file that opens Access at a specific record. This I can do, but now I need to also run it on either 32 or 64 bit systems.

Our company uses a mix of systems.

This is what I have so far:

if EXIST "C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE" 

GOTO x64
ELSE GOTO x32

:x64 
start "" "C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE" "K:\R&D Dept\Development Lab\R&D Test Request System (For testing and training)\DataBase\R&D Project Requests DB.accdb" /x mcrEmail /cmd 1912

:x32 
start "" "C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" "K:\R&D Dept\Development Lab\R&D Test Request System (For testing and training)\DataBase\R&D Project Requests DB.accdb" /x mcrEmail /cmd 1912

pause

I tried running this is the trial version of CMDebug, when I hit the :x64 line my program runs but then it also hits the :x32 line.

When trying to run this just as a batch file by clicking on it nothing happens. I'm running Access 2016 on a 64 bit system, Windows 10. My office apps are also 64 bit.

Not sure what I'm going wrong?

vidarlo
  • 3,775
  • 1
  • 12
  • 25

1 Answers1

0

try this:

@echo off
if EXIST "C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE" GOTO x64
if EXIST "C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" GOTO x32

echo No MSACCESS.EXE found - press key to exit
pause > nul
exit

:x32 
start "C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" "K:\R&D Dept\Development Lab\R&D Test Request System (For testing and training)\DataBase\R&D Project Requests DB.accdb" /x mcrEmail /cmd 1912
GOTO finished

:x64 
start "C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE" "K:\R&D Dept\Development Lab\R&D Test Request System (For testing and training)\DataBase\R&D Project Requests DB.accdb" /x mcrEmail /cmd 1912
GOTO finished

:finished
echo normal script end
pause > nul
exit

Regarding your access parameters i did not change anything as i do not know the details.

Please leave some feedback if it was helpful, or if you need some improvements. If it helped mark it as answered.

An-dir
  • 156
  • 5