Wednesday, 17 June 2009

Spawning an executable from VB.net (using file type association)

Right, this one took longer than it should.

Wanted to:
  • Open webpage using default browser (not necessarily IE)
  • Open a CSV file using Excel

So it should be simple. filename stores "c:\mycsv.csv" or http://www.nowhere.com)

Option 1: Shell(filename)
Didn't work. End of.

Option 2: ShellExecute(0, vbNullString, filename, vbNullString, vbNullString, vbNormalFocus)
Works great on Vista, no good on XP. Didn't do anything.

Option 3: System.Diagnostics.Process.Start(filename)
Works fine on both. Brilliant. Job done.

No comments:

Post a Comment