Using ShellExecute on a VB.Net App

  • Thread starter Thread starter Brent Stevenson
  • Start date Start date
B

Brent Stevenson

We have an application that monitors multiple VB.Net executables to ensure
they are still running on a server. When one of the pre-determined
executables
crashes our monitor applications uses the "ShellExecute" command to restart
the application. The VB.Net application uses a config file to store
application settings, it uses the
System.Collections.Specialized.NameValueCollection class to reterieve these
values. Retreival of the values works fine
when the VB.Net application is started from a Batch file, or initated from a
Shortcut, but when initiated using the "ShellExecute" command the values
retrieved have a zero length string, they weren't found. The application is
started so the parameters used in the "ShellExecute" command would appear
correct,
it just doesn't find the Config file using this initiation technique. The
Config file uses the executable_name.exe.config naming format and is stored
in the
same directory as the executable.

Please advise.

Thanks Brent
 
Hi!

Is the working directory the same as that of the VB.NET application when
ShellExecute happens? Ensure that this is so.

Regards,
Kumar Gaurav Khanna
--
----------------------------------------------------------------------------
----------
Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
http://www.wintoolzone.com/
OpSupport - Spelunking Rotor
http://opsupport.sscli.net/
 
Hi!

Yes, the .NET apps must "find" themselves in the folder they are present,
when executed. When this "working" folder isnt the same, the config files
willnot be located. Specify the "Default Directory" argument of the
ShellExecute API to be the folder of the .NET application to make the
working directory same as the folder of the .NET app.

Regards,
Kumar Gaurav Khanna

--
----------------------------------------------------------------------------
----------
Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
http://www.wintoolzone.com/
OpSupport - Spelunking Rotor
http://opsupport.sscli.net/
 
Back
Top