0

Question; Is there a way to direct this Batch file to the latest Version Folder (highest year) of AutoCAD 20xx found in the C:\Program Files\Autodesk\..?


General Background;

A number of staff run this Batch file, the code is shown below (FYI: I'm only showing the part necessary for this question).

Basically the batch file opens an *.EXE (Autocad) and then applies a script and a whole bunch of other stuff that isn't relevant to mention. Anyways, Each user is running different Versions (Year) of this program on their PC, thus each user has to manually edit the batch to their installed Version before running (i.e 2022, 2019, 2017, etc) or it'll start throwing errors.

Code; For 2022 Version user

"C:\Program Files\Autodesk\AutoCAD 2022\acad.exe"

Code; For 2019 Version user

"C:\Program Files\Autodesk\AutoCAD 2019\acad.exe"

GOAL

Code; For any Version

"C:\Program Files\Autodesk\AutoCAD *HIGHEST AutoCAD FOLDER NUMBER*\acad.exe"

Also to answer the obvious, I know this could be solved by all users just adopting to use the ONE version, but some users are refusing to upgrade, but that's another story...

2 Answers 2

0

It's probably going to be messy but the easiest way would be to use multiple if/else statements if its only a few year versions.

See Here for information on that

You can use code like that to check if the newest version exists, and then run it. Else if it doesn't exists,check the next version and run that, etc.

0

Use a for /d loop to catch the last (by name) matching folder into a variable:

for /D %%a in ("C:\Program Files\Autodesk\AutoCAD *") do set "ACFolder=%%a"

See for /? for details.

If you want, replace set "ACFolder=%%a" with `set "ACexe=%%a\acad.exe"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .