Run vcvarsall.bat on launch

You have encountered a problem using Far Manager? Here you can get help.
Post Reply
amb85
Posts: 7
Joined: Sun 12 Jun, 2022 12:23

Run vcvarsall.bat on launch

Post by amb85 »

I currently use the windows terminal with a custom developer command prompt that runs vcvarsall.bat on launch. I’d like to configure FarManager to do the same but I can’t figure out how to do so. Has anyone else done this and can explain the steps needed? Thanks.
User avatar
buniak_a_h
Posts: 4262
Joined: Sat 20 Apr, 2013 00:17
Location: Санкт-Петробад
Has thanked: 222 times
Been thanked: 644 times
Contact:

Run vcvarsall.bat on launch

Post by buniak_a_h »

Ctreate file %FarProfile%\Macros\internal\Shell__.lua and write:

Code: Select all

Macro {
  description="";
  area="Shell"; key="_";
  flags="RunAfterFARStart";
  code="Keys(\"v c v a r s a l l . b a t Enter\")";
}
Restart Far
amb85
Posts: 7
Joined: Sun 12 Jun, 2022 12:23

Run vcvarsall.bat on launch

Post by amb85 »

Thanks. I should have been more specific with the vcvarsall.bat call. I need to run the full path:

Code: Select all

Macro {
    description="";
    area="Shell"; key="_";
    flags="RunAfterFARStart";
    code="Keys(\"\"%ProgramFiles%\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x64 Enter\")";
}
However I get an error that there is an unexpected symbol near '\' in the Keys line.

I need to execute the batch script at the given path and pass it the x64 argument.
Shmuel
Posts: 6836
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 530 times

Run vcvarsall.bat on launch

Post by Shmuel »

amb85, make a batch file with the content like this:

Code: Select all

set VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat"
call %VCVARSALL% x86 > nul
<path-to-Far>\Far.exe
amb85
Posts: 7
Joined: Sun 12 Jun, 2022 12:23

Run vcvarsall.bat on launch

Post by amb85 »

Shmuel that worked perfectly, thank you very much!
amb85
Posts: 7
Joined: Sun 12 Jun, 2022 12:23

Run vcvarsall.bat on launch

Post by amb85 »

Actually, I don't think that does work. When I open a project in VSCode from FarManager with

Code: Select all

code .
then try calling

Code: Select all

cl.exe
for example, it doesn't find cl on the path (which it should be if vcvarsall has run successfully).
Shmuel
Posts: 6836
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 530 times

Run vcvarsall.bat on launch

Post by Shmuel »

amb85, it works for me.
If I run Far directly then cl is not found. If I run the batch everything's OK.

P.S. I don't have VSCode, I run cl from the Far's command line.
Last edited by Shmuel on Sun 12 Jun, 2022 16:24, edited 1 time in total.
amb85
Posts: 7
Joined: Sun 12 Jun, 2022 12:23

Run vcvarsall.bat on launch

Post by amb85 »

Do you launch the file directly or as the command from the windows terminal profile?
Shmuel
Posts: 6836
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 530 times

Run vcvarsall.bat on launch

Post by Shmuel »

I tried 2 ways (with the same result):
  1. From Far command line
  2. From the Windows terminal
amb85
Posts: 7
Joined: Sun 12 Jun, 2022 12:23

Run vcvarsall.bat on launch

Post by amb85 »

Okay, I'll try again. I set the batch script as the entrypoint for a Windows terminal profile, so that the profile loads Far Manager on startup. Perhaps there's some issue where that vcvarsall command to nul gets discarded before Far starts?
Shmuel
Posts: 6836
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 530 times

Run vcvarsall.bat on launch

Post by Shmuel »

amb85, if you pasted my example "as is" it wouldn't work for you, as there is my path to vcvarsall.bat there (it most probably differs from your path).
amb85
Posts: 7
Joined: Sun 12 Jun, 2022 12:23

Run vcvarsall.bat on launch

Post by amb85 »

Shmuel thank you. That's very embarrassing; having changed the path to my correct VS2022 location it works. Funny that! Thanks again for your help.
Post Reply

Return to “Support and Troubleshooting”