(This is not VBA but posting here..)
I have managed to set up Local Debugging and not external attach type for a particular VBScript (.vbs) or JScript (.js) file in Visual Studio.
Tested with Visual Studio Community 2019 and 2022.
Configuring Visual Studio
The Visual Studio installation is minimal, no workloads are installed only these individual components:
- JavaScript and TypeScript language support
- TypeScript 4.3 SDK
- Just-In-Time debugger
Create a new Visual Studio EXE project for cscript.exe
- Start Visual Studio
- click Continue without code
- select File > Open > Project/Solution
- navigate to and open cscript.exe in C:\Windows\SysWOW64 (32-bit worked for me)
- click Ignore the elevated permission warning for this directory (we will change the working directory later)
The cscript file appears in the Visual Studio solution:
Change properties for the cscript exe project
For example I have a foo.vbs file in my D:\WSH\ directory.
- Open cscript exe project Properties in Solution Explorer
- Set the Working directory to the script location: D:\WSH
- Set Arguments to: //d foo.vbs
- Change Debugger Type to Script