如何使用VBScript打开文件?

时间:2010-08-09 08:32:01

标签: vbscript

如何使用VBScript打开文件,就像用户双击文件一样?

3 个答案:

答案 0 :(得分:9)

CreateObject("WScript.Shell").Run("""C:\Program Files\my_html_files\file.htm""")

在这些注册表项中检查使用.htm扩展名注册的应用程序(可能是IExplore.exe):

HKLM\SOFTWARE\Classes\.htm
HKLM\SOFTWARE\Classes\htmlfile\shell\open\command
HKCU\Software\Classes\.htm

答案 1 :(得分:2)

CreateObject("WScript.Shell").Run("C:\\Program Files\\my_html_files\\file.htm")

答案 2 :(得分:1)

http://msdn.microsoft.com/en-us/library/bb774148(VS.85).aspx

<script language="VBScript">
function fnShellExecuteVB()
    dim objShell

    set objShell = CreateObject("Shell.Application")

    objShell.ShellExecute "notepad.exe", "", "", "open", 1

    set objShell = nothing
end function
</script>