Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open file with default application in cmd?

I'm trying to open a file in it's default editor after the user has created the file. So far my script is:

@echo off @echo --- Create A New File --- @echo - @echo Where should we put the new file? set /p fileLocation=@ %UserProfile%\ @echo - @echo What do you want to call your new file? set /p fileName=@  @echo - @echo Almost Done! What is the files extension? set /p extension=@ . @echo - copy NUL "%UserProfile%\%fileLocation%\%fileName%.%extension%" 

(ignore the extra echos and '@' those are just for fun)

After I click the file, it does the command: Choose Location > Choose File Name > Choose File extension. I'm almost done on what I want but theres one last thing. How can I get the file name that I created and then open in its default text-editor?

like image 908
omnix Avatar asked Sep 16 '10 17:09

omnix


People also ask

How do I open a program in command prompt by default?

Tap on the Windows-key, type cmd.exe and select the result to open the Command Prompt. Type control /name Microsoft. DefaultPrograms /page pageDefaultProgram to open the "Set your default programs" Control Panel window.

How do I open a file with a specific application?

To open a file in a different application:From the desktop, right-click the desired file. From the drop-down menu, click Open with, then select the desired application. In this example, we'll select Paint. The file will open in the selected application.


1 Answers

You can use start to open the file with the associated application.


Resources :

  • Open a File in the Default Application using the Windows Command Line (without JDIC)
like image 112
Colin Hebert Avatar answered Sep 19 '22 15:09

Colin Hebert