“打开方式"通过 vbscript 选项 [英] "Open with" Options through vbscript
本文介绍了“打开方式"通过 vbscript 选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们手动右键单击文件并选择打开方式"选项以其他格式打开.
Manually we right click on a file and select the "open with" option to open in other format.
现在我需要通过 vbscript 来做到这一点
Now i need to do this through vbscript
推荐答案
要使用特定应用程序打开文件,请使用 WshShell.Run
方法来运行该应用程序并将文件名作为参数传递.
To open a file using a specific application, use the WshShell.Run
methood to run that application and pass the file name as a parameter.
以下是在记事本、Internet Explorer 和 Microsoft Word 中打开相同文本文件的示例:
Here's an example that opens the same text file in Notepad, Internet Explorer and Microsoft Word:
strFileName = "c:\myfile.txt"
Set oShell = CreateObject("WScript.Shell")
oShell.Run "notepad " & strFileName
oShell.Run "iexplore " & strFileName
oShell.Run "winword " & strFileName
请注意,如果文件名包含空格,则需要将其括在引号中,如下所示:
Note that if the file name includes spaces, you need to enslose it in quotes, like this:
oShell.Run "winword ""c:\my file.txt"""
这篇关于“打开方式"通过 vbscript 选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文