Here’s the settings I have for my .cmd
and .bat
files to build them.
{
"file_patterns": ["*.bat", "*.cmd"],
"selector": "source.batch",
// This opens and runs in cmd console
"cmd": ["cmd.exe", "/C", "START", "${file_path}", "${file_name}"]
}
The filepath for the batch file is:
W:\Apps (Portable)\Batch + PowerShell\DOS\Change directories.cmd
This is the code I’m using in the batch file:
@echo off
title This will cd into the fullDir variable....
set "fullDir=C:\Program Files"
cd /d %fullDir% &rem changes into the full directory 'C:\Program Files'.
echo You're now cd' into the '%cd%' directory.
title This will cd into the current folder of the batch file...
%~d0 &rem Changes into the current drive
cd /d %~d0 &rem Changes into the current directory
echo You're now cd' into the '%cd%' directory. &rem This is now your full path of the batch file cd' into.
pause & exit
The problem I’m facing is if I run the batch file by double-clicking I get this:
You're now cd' into the 'C:\Program Files' directory.
You're now cd' into the 'W:\Apps (Portable)\Batch + PowerShell\DOS' directory.
But using Tools>Build System>Batch with the settings above I get this:
You're now cd' into the 'C:\Program Files' directory.
You're now cd' into the 'C:\Program Files' directory.
You can see the issue here is that the last example is wrong for the 2nd path.
How can I get around this? Thanks.
If there was a way of just mimicking a double click on the file that would do.