VBAHole22 Posted October 19, 2004 Posted October 19, 2004 I want to run something from within VB.NET that just sends a command to the dos prompt command line. I know there is alot of code out there to pass in an .exe filename and have it run but that isn't what I need. I need to run a program that accepts a filename as a param. So I basically just need to send the following to the dos prompt: fme base.fme fme is the program and that is the way it is called from the command line so I just need to send that statement. Also the file base.fme is in a working directory so I need to specify that as well somehow but I think I can do that like so: fme c:\base.fme Can this be done? Quote Wanna-Be C# Superstar
Wile Posted October 19, 2004 Posted October 19, 2004 Do you want to read the commandline used when starting your application, or do you want to start another application with a specific commandline? In the first case you might try reading http://www.xtremedotnettalk.com/showthread.php?t=81222&highlight=commandline In the second case, the MS documentation about System.Diagnostics.Process.Start(string, string) method: extract from Microsoft MSDN Process.Start Method (String, String) Starts a process resource by specifying the name of an application and a set of command line arguments, and associates the resource with a new Process component. Visual Basic Overloads Public Shared Function Start( _ ByVal fileName As String, _ ByVal arguments As String _ ) As Process C# public static Process Start( string fileName, string arguments ); Parameters fileName The name of an application file to run in the process. arguments Command line arguments to pass when starting the process. Quote Nothing is as illusive as 'the last bug'.
VBAHole22 Posted October 19, 2004 Author Posted October 19, 2004 Don't think that answers my issue. I don't want to run an .exe. My program is not an .exe. It is run by issuing the command fme at the dos prompt followed by a file name. If I use the process model then I will be running the file as an .exe and this has unintended consequences because it will run under a different program so : fme base.fme is completely different from Process.Start Method ("base.fme") because the latter will run as an exe while the former will run based on what is in the PATH variable for fme. All I need is to be able to replicate the process of opening a dos prompt and typing two words and hitting enter. Quote Wanna-Be C# Superstar
Administrators PlausiblyDamp Posted October 19, 2004 Administrators Posted October 19, 2004 Is fme and executable? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
VBAHole22 Posted October 19, 2004 Author Posted October 19, 2004 There is an exe called fme.exe at the path specified in the environ path variable. But it appears that the program functions in different ways depending on how you call it. If I try to use the process.start method I get the GUI version of the program which is not what I want. Quote Wanna-Be C# Superstar
Administrators PlausiblyDamp Posted October 19, 2004 Administrators Posted October 19, 2004 Have you tried Dim ps As New ProcessStartInfo ps.FileName = "base.fme" ps.UseShellExecute = True Dim p As New Process p.StartInfo = ps p.Start() Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
VBAHole22 Posted October 20, 2004 Author Posted October 20, 2004 Nope. That gets me the GUI with my mapping file loaded into it and then I have to manually fire it off. It's just not the same as typing it in at the prompt. Wish there was I was I could just emit the text I want to the prompt and then simulate hitting the Enter key. Quote Wanna-Be C# Superstar
Wile Posted October 21, 2004 Posted October 21, 2004 Are you sure that the commandline "fme base.frme" runs fme.exe, and not some fme.bat or even old DOS style fme.com program? That might be the trick how they see that they are started from the command line.... Quote Nothing is as illusive as 'the last bug'.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.