Programming, technology, and CRM – from a Belgian programmer exiled to Missouri
  • rss
  • Home
  • Soft Gallery
    • autosvnbackup.sh
    • VBScript Snippets
  • Contact Me
  • Welcome

Open file with associated application from VBScript

Nicolas Galler | September 2, 2007

What 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!

Categories
Programming
Comments rss
Comments rss
Trackback
Trackback

« Raising Events in a SQL Server trigger Excel Conditional Formatting "moves" with selection, when set from VBScript »

Leave a Reply

Click here to cancel reply.

Categories

  • Experiments (4)
  • Interesting (1)
  • MSCRM (1)
  • Programming (60)
  • Rant (3)
  • Saleslogix (34)
  • Tricks (8)
  • Uncategorized (30)

Post History

  • 2010
    • January (3)
    • March (3)
    • April (2)
    • August (2)
  • 2009
    • March (2)
    • April (1)
    • May (3)
    • June (3)
    • July (1)
    • September (3)
    • October (2)
    • December (5)
  • 2008
    • January (9)
    • February (4)
    • March (9)
    • April (1)
    • May (5)
    • June (8)
    • July (1)
    • August (2)
    • September (1)
    • November (1)
    • December (3)
  • 2007
    • January (3)
    • February (7)
    • March (1)
    • April (3)
    • May (6)
    • June (2)
    • July (1)
    • August (2)
    • September (5)
    • October (3)
    • November (5)
    • December (4)
  • 2006
    • January (2)
    • September (1)
    • November (3)
    • December (4)
  • 2005
    • April (1)

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox