0

When I create a .txt in a batch file it asks me to choose a program to read it. How do I make it reconize it as a .txt and use notepad to open?

For example if i create it like:

Echo Hello world >>learn'n.txt
start learn'n.txt

The start command would not work because it is classified as a "file" and not a .txt However:

Start learn'n

Opens a dialog box asking what program to use to open learn'n with.

Thanks for your help!

MoRsIz10n
  • 3
  • 2

3 Answers3

0

As stated by Mark Ursino on Open text file and program shortcut in Windows batch file

Echo Hello world >> learn'n.txt
start notepad "learn'n.txt"

I agree with jeremyjjbrown that you shouldn't use apostrophes in filenames.

Community
  • 1
  • 1
Z_AHK
  • 71
  • 1
  • 10
0

You can just call notepad with the file as a parameter:

notepad learn'n.txt

You can check what the file type is for the .txt extension using the assoc command

C:\>assoc .txt
.txt=txtfile

On my machine .txt files are associated as a txtfile. You can then check what the default program for that file type is using the ftype command.

c:\>ftype txtfile
txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1

On my machine, files with type txtfile are opened with notepad.exe. Presumably, you need to set this value, to do that, use the following command (obviously putting in the correct path).

ftype txtfile=path\to\NOTEPAD.EXE %1

Though for you it is probably easier to just use notepad learn'n.txt.

unclemeat
  • 5,029
  • 5
  • 28
  • 52
0

This is another option:

Echo Hello world >>learn'n.txt
start "" "learn'n.txt"

on a normal system where .txt files are associated/registered to Notepad (or another editor) then it will open the file.

foxidrive
  • 40,353
  • 10
  • 53
  • 68