Can I start the default file editor from a batch file?

History:

We can use a combination of PATHEXTWindows file associations for the equivalent Command Prompt by right-clicking the file in Explorer and clicking Open , for example:

C:\code\python> echo print "Hello, StackOverflow!" >hello.py

C:\code\python> hello
Hello, StackOverflow!

Similarly, I could use this to start Photoshop by typing:

C:\art\source> StackOverflowLogo.PDF

Actual problem:

I need a command line equivalent to right-clicking on a file in Explorer and instead select Modify .

With my welcome (.py) above, the Python Idle editor is likely to appear . However, I need a generic solution that uses OS-level association for the file type. I can’t accept this.

The simplest example of what I would like to do is a hypothetical EDIT.BAT file that will do nothing but launch the editor for a given file name:

@InsertMagic /Here %1

Thank! (I hope so).


Aaand ... solution:

Alex C. offers Powershell, which of course is a great solution. Therefore, to write my EDIT.BAT above, I could do this:

@powershell -command "start -verb edit '%1'"

(This is a bit naive as there are potential issues with quoting, but you get the idea.)

Cheers for a quick reply. :)

+4
1

Shell Verbs, , - .

Win7/2k8r2 PowerShell, :

powershell -command "start -verb edit 'C:\art\source\StackOverflowLogo.PDF'" 
+3

All Articles