how to pass parameters to tortoiseproc.exe via file?

大憨熊 提交于 2019-12-14 02:51:32

问题


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?


回答1:


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"




回答2:


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.




回答3:


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


来源:https://stackoverflow.com/questions/5694423/how-to-pass-parameters-to-tortoiseproc-exe-via-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!