关联和文件类型命令在Powershell下无法使用。

28

我以为在Powershell下所有cmd命令都可以使用。例如assocftype不能使用。有没有方法可以让它们工作,而不是再次切换到cmd

3个回答

29

这些功能可以使用,但需要通过cmd.exe调用它们,因为它们不是实际驻留在磁盘上的程序,而是内置于cmd.exe中的功能,如下所示:

cmd /c assoc
cmd /c ftype


虽然这是完全可行的,但没有直接在Powershell中完成这个任务的方法吗? - Alexandros

4

在扩展Eric的回答,以下是如何使assocftype在powershell中“正常工作”的方法。

将此添加到您的powershell profile - 您只需在powershell中运行$Profile即可找到您的配置文件:

function assoc { cmd /c assoc $args }
function ftype { cmd /c ftype $args }

0
这些答案中提供的东西显然行不通。 你需要的是:
cmd /c assoc .="zzzfile"
cmd /c  --% ftype zzzfile="C:\Program Files\Sublime Text\sublime_text.exe" "%1"

这是来自stackoverflow某个帖子上的另一个答案。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接