0

I faced error when running below script in a batch file. The file location of the batch is

"C:\Win10 LTSC GOA 2022-04\Batches_Win\AAADH_Master_Win.bat"

and the file location of the cmd file is in the same subfolder as the batch file :

"C:\Win10 LTSC GOA 2022-04\Batches_Win\CENAS_Detect_Extract.cmd"

From the error dialogue, it couldn't achieve the full directory name : Win10 LTSC GOA 2022-04 ! Appreciate any help to rectify this. Thanks.

start "" "%~dp0CENAS_Detect_Extract.cmd" "/d 1 /t 10" "default is 1 after 10 secs"

The error when ran the script is as pictured. enter image description here

enter image description here

1 Answer 1

0

Try making it like this instead for the batch:

@setlocal enableextensions
@cd /d "%~dp0"
start "" "CENAS_Detect_Extract.cmd" "/d 1 /t 10" "default is 1 after 10 secs"

@setlocal enableextensions - controls the visibility of environment variables[^] and enables cmd extensions[^].

@cd /d "%~dp0" - Changes the current directory to %~dp0 which is a special batch parameter[^] that expands to the drive and directory that batch file is located in.

%0 expands to the full path and file name of the batch file, adding the ~dp modifier in the middle to make %~dp0 reduces the %0 value to just the drive and path.

Reference

You must log in to answer this question.

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