'Open text file via batch?
I am trying to access a text file using batch when a user enters a certain command. I have tried doing
start E:\Programming\Important\Folder\Textfile
Cls
And it closes the cmd window but wont open the file. Does someone mind telling me what I did wrong? (sorry for the code not being in the gray box im using the web browser on phone)
Solution 1:[1]
I guess the problem is Textfile
has no file extension, so windows does not know how to open it. Instead of using start
you could use the notepad
command, as notepad.exe
is in the search path of the system, you can simply write:
notepad 'E:\Programming\Important\Folder\Textfile'
This will open your file.
Solution 2:[2]
You can do that easily with PowerShell, like so:
say we want to open 2 files in Sublime Text:
Start-Process -FilePath "C:\Program Files\Sublime Text 3\subl.exe" -ArgumentList D:\PathToMyFile\myFile.txt, D:\PathToMySecondFile\myFile.txt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | tanuk |