Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

I Have a separate .exe file that I need to run with an configuration file from vb.net.

I can run it fine manually by Opening the .CFG file with the Application. (using the "openwith" then selecting the app)

How can I do this from code?

 

I tried this but it didn�t work

 

Dim pProcess As New Process

Dim pProcessInfo As New ProcessStartInfo

pProcessInfo.FileName = "D:\Tools\test.exe"

pProcessInfo.Arguments = "D:\Tools\config.CGF"

pProcessInfo.UseShellExecute = True

pProcess.StartInfo = pProcessInfo

pProcess.Start()

phillip Restall
Posted
a .config or .cfg file in .net is XML-based so you can use the System.XML.XmlTextReader to read it out.(But I prefer the XmlDocument with XmlNodeList)

For questions about VS .net extensibility, please fire at me! :)

For readability, please use the [ CS][/CS ] tags

Posted

Thanks for the reply but i think you misunderstood me.

I need to open the config.cgf file using the test.exe

the config.cgf file tells the test.exe what to do.

phillip Restall
Posted
Does the test.exe allow you to specify a command line parameter?

 

No it doesn't.

I might have to get the company to change the way it works.

At the moment i write the .cgf file from my application then need to run the test.exe and some how associate the two files. (Like the open with in folders)

I'll see if the can get them to use a standard name for the .cgf and do it at there end so i only have to run the test.exe and nothing else.

phillip Restall
Posted

If test.exe doesnt accept a parameter, then you can't do it. Associating files works by passing parameters, so you can't do that either.

 

Making the cgf a standard name won't fix anything - you have to get them to change the app.

 

Do you know the company? What is the app made with?

Posted (edited)
If test.exe doesnt accept a parameter, then you can't do it. Associating files works by passing parameters, so you can't do that either.

 

Making the cgf a standard name won't fix anything - you have to get them to change the app.

 

Do you know the company? What is the app made with?

 

I Just Checked and found that the program does except a parameter.

Its is the Path of the .CGF file

 

How do i get the .exe file to take the parameter?

Edited by phillip
phillip Restall
Posted
How do i get the .exe file to take the parameter?

 

Exactly how you have done it above, except change the very last line to:

 

pProcess.Start(pProcessInfo)

 

You may want your calling application to block until the spawned process has completed. If this is the case, use:

 

pProcess.Start(pProcessInfo)
pProcess.WaitForExit()
'
'Any code here won't happen until the spawned app has exited
'

 

;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...