Jon
Jon

Reputation: 487

Open a file using a system verb from batch file

In Windows Explorer, I can right-click on a file and choose Edit (or other system actions/verbs) instead of Open. Is it possible to do this from a cmd file? I want to mimic right-clicking on a file and choosing Edit, i.e. the file should open in the program configured to handle the Edit verb.

Upvotes: 1

Views: 210

Answers (1)

David Ruhmann
David Ruhmann

Reputation: 11367

With PowerShell

PowerShell "(New-Object -com 'Shell.Application').ShellExecute('file.txt', '', '', 'edit')"

With VB Script

Set Shell = CreateObject("Shell.Application")
Shell.ShellExecute "file.txt", "", "", "edit"

See the ShellExecute (Link) function.

Upvotes: 1

Related Questions