Windows: start a file using a (non-default) shell verb like “edit” from .bat or command-line

前端 未结 4 816
醉话见心
醉话见心 2021-02-15 16:20

How can I start a file with an associated non-default command (shell verb) like \"edit\", \"print\", ... from command-line or from a .bat script by usi

4条回答
  •  眼角桃花
    2021-02-15 16:51

    An example to show how to do it with an one-liner:

    mshta vbscript:Execute("CreateObject(""shell.application"").ShellExecute""%SystemDrive%\autoexec.bat"","""","""",""edit"",1:close")
    

    It will open the dummy autoexec.bat file with the application defined to edit .bat files (by default, Notepad).

提交回复
热议问题