Call another .bat file from one folder?

I have my main batch file in a folder with a second batch file in the same folder. How to make the second batch file can be called from the first. It should be able to work with any Windows user computer.

I realized that it was something like this (in the main file):

call C:\%UserProfile%\#Hashtag\gameData\second.bat

But he says my syntax or path is wrong.

+4
source share
3 answers
call "%~dp0\second.bat"

%~dp0 gives you the path to the currently running batch file.

+6
source

Perhaps due to the folder name #hashtag this is an error. Add the folder path to the PATH variable, and then try to directly invoke the batch file name.

0

Agreeing with @Stephan, there is some invisible code change other than use %~dp0, since the path is now also in "double quotes. Most likely, the problem with the first is due to the expansion of the variable %UserProfile%... my guess is there is a space in this line.

No problem using the character #in the file name.

0
source

All Articles