Hii Friends
I have written a vb code in which i can call an external application using shell command
"Shell("C:\\abc.exe")" Now when i call this command it avtually executes this command.
But what i want is some command where i dont want to run the file but make sure that the file can run..i know the only way to make sure is by double clicking the file or by using the shell command..But i dont want to do that.Just make sure that the file will run
Is it possible????

5 Years
Discussion Span
Last Post by Oxiegen

There is really no sure way to programmatically determine whether or not another program can be run.
The only way to really it is to actually try to execute the file.
On that front, you can use the Shell commands FileNotFound exception error in order to determine if the file can be executed or not.
Like so:

Catch fx As System.IO.FileNotFoundException
   'Something went wrong with the execution of the file.
   'Either it's a 16-bit command trying to be run on a 32-bit system,
   'or the file cannot be found
Catch ex As System.Exception
   'Catch any other Exceptions here
End Try
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.