views:

1278

answers:

2

I have a ClickOnce deployed application I want to launch from VBScript, similar to launching Microsoft Word in the following example:

Dim word
Set word = CreateObject("Word.Application")
word.Visible = True

The problem is I don't know what parameter to pass into the CreateObject function to launch my application. Where would I find the master list of applications installed on my PC/the shortcut to call to launch them?

+2  A: 

ClickOnce simply isn't installed that way. They don't typically have COM hooks (for CreateObject), and are installed in an isolated part of the user's profile (not that machine's profile). And don't forget you can also get multiple copies/versions of the same app at once via ClickOnce (from different locations).

One option (in 3.5/VS2008) might be to use the new file associations stuff... associate your app with ".foo" files, create an empty ".foo" file and start it. That might work. Look on the Publish=>Options dialog in VS2008.

Otherwise - basically, if you want this type of usage, I suspect you will need to use msi (i.e. a regular installer; not ClickOnce) to register your app as a COM library (dll). Note that .NET doesn't make a good COM server (exe) - so doesn't compare directly to Word. If you want a .NET COM server, then "serviced components" are your best bet - but these don't tend to be big on UI.

For info, the isolated area is somewhere around "%userprofile%\Local Settings\Apps\2.0", but this is just for interest so you can see it.. don't try running it from there.

Marc Gravell
+1  A: 

Thanks for the info. That made me realize that I could use a .Net executable instead of a vbscript to launch my application.

    Dim program As New Process

    'Try to run a .Net click-once application
    Try
        Dim shortcut As String = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu)
        shortcut = shortcut + "specific\shorctut\path\shortcut.appref-ms"
        program .StartInfo.FileName = lpsShortcut
        program .Start()
    Catch
        'If not go to the web site for a fresh install
        Try
            .Diagnostics.Process.Start("IExplore.exe", "http://url/program.application")
        Catch ex As Exception
            'Log or Email alert here...
        End Try
    End Try
Jeff