tags:

views:

99

answers:

3

hi

How to perform the double click effect with VBScipt to open files?

Thanks

Lidia

A: 

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

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

    set objShell = CreateObject("shell.Shell_Application")

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

    set objShell = nothing
end function
</script>
Anonymous Coward
can you please give me example how to open the C:\Program Files\my_html_files\file.html filethx
lidia
I get the error message: ActiveX component cant create objecte:'shell_application' ?
lidia
It should be "Shell.Application", not "shell.Shell_Application".
fmunkert
A: 
CreateObject("WScript.Shell").Run("C:\\Program Files\\my_html_files\\file.htm")
abatishchev
file.htm exist but when I run the script I get the message that the system cant find the specific file?
lidia
Try to put script file in the same folder as target html file, remove the absolute path and try again
abatishchev
I cant because I must to run it only from this PATH
lidia
@abatishchev: Backslashes aren't special characters in VBScript, so they don't need to be escaped.
Helen
+1  A: 
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
Michel de Ruiter