View Single Post
Old Dec 2nd, 2005, 2:10 PM   #5
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Silent, what I meant was that the Shell command is simply a shortcut method for people experienced with VB6 which hides a lot of the improved native functionality you get with the .NET Framework (FW). Microsoft.VisualBasic.Interaction.Shell() will only execute natively executable files (.exe, .com) whereas the Process class enables you to call the ShellExecute API to launch so-called "helper" applications:

        Dim AProcess As System.Diagnostics.Process = New System.Diagnostics.Process
        With AProcess
            .StartInfo.FileName = "C:\Windows\Gone Fishing.bmp"
            .StartInfo.UseShellExecute = True
            .Start()
        End With

The important line is .StartInfo.UseShellExecute = True, you are instructing the class that the file is not directly executed, but run with another program defined in the registry (probably paint), whereas you cannot do this simply using the Shell method.

In your case you can substitute .StartInfo.FileName = "somefile.cmd" as command.com is the helper app for those files, which will run as if you double clicked them. N.B. you may need to specify the absolute path - AppDomain.CurrentDomain.SetupInformation.ApplicationBase() gives you the path the application is running from.
Rory is offline   Reply With Quote