Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The start command (in PowerShell an alias for Start-Process, in cmd.exe a shell builtin) does the same as the Windows Explorer context menu 'Open' action: it opens the file using the application which Windows has registered for it.

(Or are there perhaps small differences? Or perhaps it triggers the default action, which normally is the 'Open' action?)

How do I trigger the 'Edit' action for a file from the command line?

share|improve this question

2 Answers 2

The "Edit"-verb really does trigger the "Edit"-action.
(I tested it with changing the "Edit" for .reg files in the registry and running the command.)

Since you made your answer "a partial answer" did you want to know how you would do this in cmd.exe? I don't think it can be done natively in `cmd.exe'.

There is of course ShelExec.

But you can also run powershell -command "start -verb edit textfile.txt" in cmd.exe.

You can even put this in a shortcut with doskey like this:

doskey cmdedit=powershell -command "start -verb edit $1"

Now you can do cmdedit textfile.txt on the cmd.exe-prompt.

Note: for the doskey-'macro' to be available after restarting the computer/cmd-session you need to add this command in your startup-scripts. You can look here for some suggestions to making it permanent.
I would go for the option of putting it in
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun.


Edit:

This .reg file does it all for you:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"AutoRun"="doskey cmdedit=powershell -command \"start -verb edit $1\""
share|improve this answer

(Partial answer which I discovered as I was typing the question.)

For PowerShell I discovered the following:

start -verb edit ...filename...

Documentation (from get-help start-process -full):

-Verb <string>
    Specifies a verb to be used when starting the process, such as Edit, Open, or Print.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.