0

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?

Steve Crane
  • 4,340
  • 5
  • 40
  • 63

1 Answers1

4

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""");
Steve Crane
  • 4,340
  • 5
  • 40
  • 63