lidia
lidia

Reputation: 3183

How do I open a file with VBScript?

How do I open a file with VBScript, as if the user had double clicked the file?

Upvotes: 10

Views: 122791

Answers (3)

Anonymous Coward
Anonymous Coward

Reputation: 73

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>

Upvotes: 1

Michel de Ruiter
Michel de Ruiter

Reputation: 7954

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

Upvotes: 14

abatishchev
abatishchev

Reputation: 100238

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

Upvotes: 3

Related Questions