how to pass parameters to tortoiseproc.exe via fil

2019-07-27 21:42发布

I am programmatically generating a command to be submitted to cmd.exe using Runtime.getRuntime.exec() from java.

The command is tortoiseproc ignore command of the form

tortoiseproc /command:ignore /path:file1*file2*file3*...................filen

As you can see, the path parameter takes a number of files and problem occurs when this string exceeds a certain length approx. 8197 characters as documented in microsoft KB for cmd.exe.

The workaround there says that modify the program so that it accepts the parameters from a file rather than from the commandline string. Does anybody know how to pass parameters to tortoiseproc.exe via file?

3条回答
欢心
2楼-- · 2019-07-27 21:56

I had same problem and this is my solution for that:

using (var s = File.Create("D:\\p3.tmp"))
{
    using (var sw = new StreamWriter(s, new UnicodeEncoding(false, false)))
    {
        sw.Write(@"D:\SourceCode\Utils\ProductProvider.cs" + '\n');
        sw.Write(@"D:\SourceCode\Utils\BillingProvider.cs"+ '\n');
    }
}

after file is created I use

TortoiseProc.exe /command:commit /pathfile:"D:\p3.tmp" /logmsg:"test log message" /deletepathfile
查看更多
Juvenile、少年°
3楼-- · 2019-07-27 22:06

Nope, that's not possible. However, in this specific case, it doesn't matter: you can split the file list into multiple smaller ones, and run the tortoiseproc multiple times. Example:

tortoiseproc /command:ignore /path:file1*file2*file3*file4
tortoiseproc /command:ignore /path:file5*file6*file7*file8

and so on, up to file n.

查看更多
爷、活的狠高调
4楼-- · 2019-07-27 22:09

you can pass a file in utf16 format, with each file listed on a separate line.

Pass the path to that file with /pathfile:"path/to/file.txt"

查看更多
登录 后发表回答