要使用特定应用程序打开文件,请使用WshShell.Runmethood运行该应用程序并将文件名作为参数传递.
这是一个在记事本,Internet Explorer和Microsoft Word中打开相同文本文件的示例:
strFileName = "c:\myfile.txt"
Set oShell = CreateObject("WScript.Shell")
oShell.Run "notepad " & strFileName
oShell.Run "iexplore " & strFileName
oShell.Run "winword " & strFileName
Run Code Online (Sandbox Code Playgroud)
请注意,如果文件名包含空格,则需要将其括在引号中,如下所示:
oShell.Run "winword ""c:\my file.txt"""
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18684 次 |
| 最近记录: |