Open file with associated application from VBScript
Nicolas Galler | September 2, 2007What I want to do is execute a file with the application that has been associated with it. For example given an xls file it should open with Excel. Well you’d think that would be an easy one, but cmd.exe is a bit funky in how it handles quote characters.
Here is one that works… you have to pass the title to the START command:
Dim wsh
Set wsh = CreateObject("WScript.Shell")
wsh.Run "cmd /min /c start ""Opening File"" """ & sPath & """"
Note that this one works, but it keeps the command window opened:
wsh.Run "cmd /min /x /c """ & sPath & """"
I think you can actually just use this in most cases:
wsh.Run """" & sPath & """"
I must have had to look this up 3 or 4 times, hopefully now I’ll remember!





