How do I open a file with VBScript, as if the user had double clicked the file?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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
回答2:
CreateObject("WScript.Shell").Run("C:\\Program Files\\my_html_files\\file.htm")
回答3:
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>