简体   繁体   中英

Why does this LINQPad Util.Cmd() call fail?

I'm trying to execute the Windows find command from LINQPad but it isn't working and I don't understand why. This is my LINQPad script and I'm executing it in LINQPad as C# Statement(s).

string find = @"find ""Processing request to "" ""Y:\Services\DynaMiX.Services.DatabaseMaintenance\*.log""";
find.Dump("find");
var results = Util.Cmd(find);
results.Dump();

The find.Dump("find") statement displays the following as expected.

find "Processing request to " "Y:\Services\SteveC.Services.DatabaseMaintenance\*.log"

When I copy that and paste it in a CMD window it executes the find as it should but when running the script in LINQPad it throws CommandExecutionException with the ErrorText FIND: Parameter format not correct .

Can anyone shed any light on why this might happen?

Turns out to be an incorrect use of Util.Cmd on my part. Instead of Util.Cmd(string commandText) I needed to use the Util.Cmd(string commandText, string args) overload. The following statement works.

var results = Util.Cmd("find", @"""Processing request to "" ""Y:\Services\SteveC.Services.DatabaseMaintenance\*.log""");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM