PowerShell脚本更改tiff和tiff文件的关联
问题描述:
我一直在试图制作bat脚本或PowerShell脚本,将.tif和.tiff文件的关联文件更改为Modi中的MSP程序。PowerShell脚本更改tiff和tiff文件的关联
我目前糟糕的代码看起来是这样的,它不会与微软MSP程序正确打开文件
assoc .tif=TIFImage.Document
ftype TIFImage.Document="C:\Program Files (x86)\Common Files\microsoft shared\MODI\12.0\MSPVIEW.exe" "%1"
assoc .tiff=TIFImage.Document
ftype TIFImage.Document="C:\Program Files (x86)\Common Files\microsoft shared\MODI\12.0\MSPVIEW.exe" "%1"
答
assoc
和ftype
是CMD内置命令,而不是外部程序,所以你需要运行他们通过cmd /c
如果你想从PowerShell使用它们。此外,PowerShell在分析参数到ftype
命令时会做些时髦的事情,所以您需要“魔法参数”(--%
)来阻止它这样做。
cmd /c assoc .tif=TIFImage.Document
cmd /c assoc .tiff=TIFImage.Document
cmd /c --% ftype TIFImage.Document="C:\Pro...IEW.exe" "%1"
是否有与此代码等价的powershell? – user1378803
你是什么意思“等效的PowerShell”? *是您在PowerShell中运行的代码。 –
我的意思是只使用ps ...上面的代码调用cmd ...有没有办法在ps中做到这一点? – user1378803