Search code examples
windowsbatch-filecmdnativegraalvm-native-image

How to associate bat files to x64 Native Tools Command Prompt for VS 2022 in Windows 11?


For the link below

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2022.lnk

the properties follows:

Target: %comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
Open File Localtion: C:\Windows\System32\cmd.exe

How to change double click behaviour of bat files from "cmd" to "x64 Native Tools Command Prompt for VS 2022" to use graalvm features like native-image?


Solution

  • as @GregHNZ answered, below is an example bat file content to compile native, that can be called by doubleclick

    call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
    native-image -H:ConfigurationFileDirectories=config -march=compatibility --enable-url-protocols=http,https --enable-preview --add-modules jdk.incubator.vector -jar target\com.tugalsan.gvm.vnc.web-1.0-SNAPSHOT-jar-with-dependencies.jar com.tugalsan.gvm.vnc.web