简体   繁体   中英

How do I open a file with VBScript?

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

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

And check the application registered with the .htm extension (probably IExplore.exe ), in these registry keys:

HKLM\SOFTWARE\Classes\.htm
HKLM\SOFTWARE\Classes\htmlfile\shell\open\command
HKCU\Software\Classes\.htm
CreateObject("WScript.Shell").Run("C:\\Program Files\\my_html_files\\file.htm")

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM