0

How do I open a .bat file as a text file in notepad from another batch script.

What I actually want is to open a file b.bat in notepad using a batch script say a.bat

i tried:

start notepad tools_OriginalBuild\repository_test.bat

doesn't work

Cravenica
  • 177
  • 9
  • Show us the code you're using from your batch file as part of your question, not just a line, but the raw code. – ManoDestra Jul 06 '16 at 13:34
  • And what do you mean by "doesn't work"? You need to be more descriptive of what error you're getting. At the moment, your path above is relative, so it will depend on where your batch file is run from. You could use `%~dp0\tools_OriginalBuild\repository_test.bat` instead as your path inside your batch file, to remove that problem. – ManoDestra Jul 06 '16 at 13:41

2 Answers2

2

At the moment, your path is relative, so you could only run that batch file from the directory containing the batch file (provided the relative path given is correct). Running it from any other directory would result in an error about the file not being found.

You can eradicate this problem, by always running relative to the batch file's location using the following code inside your batch file:

notepad %~dp0\tools_OriginalBuild\repository_test.bat

Information on this format can be found here: What does %~dp0 mean, and how does it work?

This makes the assumption that that sub directory exists and the file exists, of course. You could check for its existence first, if you wish, but that's another question for you to investigate on your own :)

Community
  • 1
  • 1
ManoDestra
  • 5,756
  • 6
  • 22
  • 48
1
notepad "c:\folder\file.bat"

Is how.