JPL
JPL

Reputation: 57

C# start process multiple times

I do have one windows-based C# application that calls one external scan.exe file to scan one directory.

Below the codes I do the process call:

Process p = new Process();
p.StartInfo.FileName = @"Scan.exe";
foreach (FileInfo file in fileList)
{
    p.StartInfo.Arguments = @" /ALL /ARCHIVE " + file.FullName;
    p.Start();
    //System.Threading.Thread.Sleep(200);
}

When I run it, the Scan.exe file pops up (with UAC windows) with every file name passed in. Supposedly, in the list, there are six files, the scan.exe pops up 6 times.

Is there a way I can open create one process and reuse it in the for loop?

Thanks

Upvotes: 2

Views: 2481

Answers (2)

Luc Morin
Luc Morin

Reputation: 5380

Like explained by someone else's comment, unless the program was designed to accept multiple files to scan on one command line call, there's nothing you can do about it in your own code.

What I would do, I would find the reference manual for scan.exe, and find out if it's possible to call it, passing it a filename, which file would contain the list of files to scan.

Since you don't provide the exact product version, I can only guess. According to this link, scan.exe accepts a CHECKLIST parameter:

/CHECKLIST=<filename>   Scan list of files contained in <filename>.

Again, I don't know if this applies to your specific version of scan.exe, but you can find out, I'm sure of that ;-)

Cheers

Upvotes: 0

Scott Chamberlain
Scott Chamberlain

Reputation: 127543

If you don't want to be asked for every file the program running your code must be an administrator. You can make your program automatically prompt for administrator by adding a manifest file and setting the requestedExecutionLevel tag to

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Upvotes: 1

Related Questions