views:

10

answers:

0

I am launching a VB.NET (2.0) application using WSHShell from a startup VBS script.

This application has 2 images located in an /Images folder in the VB.NET project with a 'Build Action' of 'Content'. When the application runs it does some checking and then tries to show one of the 2 possible images as follows:

imgStatus.Image = Image.FromFile(imagePath, True)

This causes a FileNotFoundException with a message of "Images\myImage.png The same error occurs if a launch the application using the following code after startup:

Dim WSHShell
Set WSHShell=WScript.Createobject("wscript.shell")
WSHShell.Run """C:\Program Files\MyCompany\MyProduct\MyApplication.exe"""

However it all works fine if I double click on the exe.

So my first question is why is there a difference between the 2 methods of launching?

The application is installed using a standard Setup Project which installs the Primary Output and Content of MyApplication. So I end up with the a folder containing MyApplication.exe (and its DLL's) and an Images folder.

To make it more complicated, when I install the same application on my development machine, then I can launch it ok from the same VBS script.

I used a 7Zip to look at the contents of the installed exe folder on the 2 machines and they are totally different. On the problematic machine I just get .text, .rsrc and .reloc files but on my dev machine it looks like the contents of the \bin\debug (including an 'Images' sub-folder).

So my second question is why am I seeing different views of the .exe ?

I will look at either providing a fully qualified image path or using embedded resources to solve the problem but I'm just curious as to the differences.

Thanks, Canice.