Question

I'm using process.Start to run Convert.exe. This program's purpose is to convert all files which are in the exe's folder. So when I normally use it, I copy paste a file into the same folder as Convert.exe and then run Convert.exe. Convert.exe will create a new "converted" file in the same folder.

I'm trying to automate this tedious process. A User selects a file which needs to be converted from FolderA, I copy it to the same folder where Convert.exe is and I'm using process.start(Convert.exe) to run it. Just to be clear, this "Convert.exe" accepts NO arguments.

The problem: "Convert.exe" is not converting the files in its folder. Instead it's converting all the files in FolderA for some weird reason. I don't know why it picked that folder, I never even try to send it as an argument or nothing.

Here's the code I have:

Dim techInfo As New System.IO.FileInfo(itm.strFilePath)             
techInfo.CopyTo(ConverterPath & techInfo.Name)

Dim procInfoConvert As New ProcessStartInfo
procInfoConvert.CreateNoWindow = False
procInfoConvert.Arguments = ""
procInfoConvert.FileName = ConverterPath & "Convert.exe"

Dim procConvert As Process = Process.Start(procInfoConvert)

I did a test where I copy pasted a file into the "Convert.exe" folder and then just run this code:

process.start(ConverterPath & "Convert.exe")

The exe returns nothing, same as if there was no files in the folder.

The only thing I can think of is that when process.Start is run, it copies the file to another location and runs it from there.

Any ideas anyone?

Was it helpful?

Solution

Try this:

procInfoConvert.WorkingDirectory = ConverterPath

That'll set the process up to start in the directory it's contained in, instead of the current directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top