Home > Enterprise >  Why won't a Batch file start in the directory it was executed in?
Why won't a Batch file start in the directory it was executed in?

Time:02-06

I am programming a DOS-like shell, but it starts in %UserProfile% instead of %UserProfile%\Desktop\Coding projects\CM-DOS. The actual shell, kernel.bat's code is:

@echo off
type INFO.txt
pause

INFO.txt is in the same directory as kernel.bat (CM-DOS). It says:

CM-DOS is a FREE, open-source Disk Operating System by Tristan Carpenter. If anyone trys to sell you a paid copy of CM-DOS, send me an e-mail at [email protected]. Please use this DOS shell kindly. This shell is licensed under the MIT License. Do whatever you want with the shell, create closed-source versions, fork it, I don't really care.

The script tries to type "%UserProfile%\INFO.txt", which doesn't exist. How can I start the file in it's actual directory, instead of %UserProfile%.

CodePudding user response:

You can add cd

  •  Tags:  
  • Related