对于Windows:;编辑&QUOT使用(非默认)外壳动词像&QUOT启动文件;从.bat或命令行 [英] Windows: start a file using a (non-default) shell verb like "edit" from .bat or command-line

查看:203
本文介绍了对于Windows:;编辑&QUOT使用(非默认)外壳动词像&QUOT启动文件;从.bat或命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何开始像编辑,打印...的命令行或从蝙蝠脚本通过与相关的非默认命令(壳动词)的文件使用标准的Windows意味着。结果
(你得到的顶部时所提供的额外的操作,在Windows资源管理器中右键单击文件。)

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 using standard Windows means.
(Those extra actions which you get offered on top upon right-click on a file in the Windows Explorer.)

因此​​获得的效果

python -c "import os;os.startfile('somepic.png', 'edit')"

(的ShellExecuteEx),但不使用额外的工具,如蟒蛇,PowerShell或左右。
START命令似乎并没有提供这一点。

(ShellExecuteEx), but without using extra tools like python, powershell, or so. The START command does not seem to offer that.

推荐答案

由于从意见,并经过进一步搜索得知:似乎有在标准Windows这项任务没有直接的命令确实结果。
但是,在使用一个VBScript代码段应高度兼容,并具有最低的系统要求。 (对所有机器在这里工作,直接 - 从XP - 不像JScript中)

As learned from the comments and after further searching: there seems to be no direct command for that task in standard Windows indeed.
However using a VBScript snippet should be highly compatible and have lowest system requirements. (Works on all machines here directly - from XP - unlike JScript)

VBScript中已经通过默认的每个桌面版本安装
  因为Windows 98的Microsoft Windows; 1 在Windows Server因为Windows
  NT 4.0选项包; [2]以及可选的Windows CE的(视
  它安装在设备)。

VBScript has been installed by default in every desktop release of Microsoft Windows since Windows 98;1 in Windows Server since Windows NT 4.0 Option Pack;[2] and optionally with Windows CE (depending on the device it is installed on).

例脚本的 shellexec.vbs 的:

' shellexec.vbs : starts a file using a (non-default) shell verb like "EDIT"
' Usage: shellexec.vbs FILE VERB
' Example: shellexec.vbs demo.png EDIT
fn = WScript.Arguments(0)
cmd = WScript.Arguments(1)
Wscript.Echo "ShellExecute """ + cmd + """ on " + fn
CreateObject("shell.application").ShellExecute fn, "", "", cmd, 1

通过命令行或批处理文件用途:

Use from command-line or batch-file:

shellexec.vbs demo.png EDIT

cscript.exe //Nologo shellexec.vbs demo.png EDIT

这篇关于对于Windows:;编辑&QUOT使用(非默认)外壳动词像&QUOT启动文件;从.bat或命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆