Automatically detect MSACCESS.EXE location

A Snippet from: Dorian Ellis

//Run CMD as hidden.
Let>RP_WINDOWMODE=0

//Wait until CMD has finished
Let>RP_WAIT=1

//Delete any old output files
DeleteFile>%TEMP_DIR%\MSaccess-location.txt

//Search both program folders for and all subfolders for MSACCESS.EXE and output to a temp file (took about 5 seconds in my tests) 
RunProgram>cmd /c dir "C:\Program Files (x86)\MSACCESS.EXE" /s /b > %TEMP_DIR%\MSaccess-location.txt
RunProgram>cmd /c dir "C:\Program Files\MSACCESS.EXE" /s /b >> %TEMP_DIR%\MSaccess-location.txt

//Alternately, we could search all of c:, but this takes about 5 seconds.
//RunProgram>cmd /c dir C:\MSACCESS.EXE /s /b > %TEMP_DIR%\MSaccess-location.txt

//Read the temp file and store the location in variable "Accessloc" 
ReadLn>%TEMP_DIR%\MSaccess-location.txt,1,Accessloc

//Check to see if the file is empty
Length>Accessloc,AccesslocLen

//If it's not empty, Access was found.
IF>AccesslocLen>0
  //Execute the temp file if you wish.
  ExecuteFile>%TEMP_DIR%\MSaccess-location.txt

  //Pop up a message containing the location 
  MessageModal>Location of Microsoft Access is : %CRLF%%CRLF%%Accessloc%

Else
  MessageModal>MSACCESS.EXE wasn't found in your C:\Program Files (x86) or C:\Program Files folders.
Endif

Select the code above to paste into your macro. Or: View Raw Text

Link: http://www.mjtnet.com/snip.htm?g=5792acdb69280

Forum Embed Code - click to select all then copy (CTRL-C):

When pasting into the forum do NOT modify the script code or it will not match what is in the database - create a new snippet instead!