1

at first - yes I read similar topics and no, it is still not working for me :(

I have quite a long command I need to call from cmdline. It containes almost all special characters like ", \, spaces... so I do not know where the mistake is...

public void PartsDatabaseCSVExport()
    {
        String command;
        String exePath = @"C:\Program Files\EPLAN\Platform\2.7.3\Bin\Eplan.exe";
        String product = "Electric P8"; 
        String configFile = @"D:\EPLAN\1_MASTER_DATA\Data\Artikl\EPLAN_CZ\csvimportexport - RMT.cfg";
        String outputFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        outputFile+="\\EPLAN_Custom\\exportC.csv";

        command = $"/k\"{exePath}\" /Variant: \"{product}\" /NoSplash /Frame:0 /Auto /Quiet partslist /TYPE:EXPORTFROMSYSTEM /SQLFILTERPART:1=1 /FORMAT:IXPamImportCSV /CFGFILE: \"{configFile}\" /EXPORTFILE: \"{outputFile}\"";

        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = "cmd.exe";
        startInfo.Arguments = command;

    try
        {
            // Start the process with the info we specified.
            // Call WaitForExit and then the using statement will close.
            using (Process exeProcess = Process.Start(startInfo))
            {
                exeProcess.WaitForExit();
            }
        }
        catch
        {
            // Log error.
        }


    }

It ignores quates marks around exePath and only get C:\Program....

Thanks for any help...

Jan Daliba
  • 29
  • 5
  • Have you tried verbatim interpolated string? $@"..." – Davide Vitali Mar 15 '19 at 10:08
  • 1
    Unless that "Eplan.exe" does read or write to console something you want to interact with, I would suggest not executing "cmd.exe" process to execute "Eplan.exe" but execute the later directly. – Cleptus Mar 15 '19 at 10:12
  • ``/k"C:\Program Files\EPLAN\Platform\2.7.3\Bin\Eplan.exe" /Variant: "Electric P8" `` it seems to work fine except that lack of space between ``k`` and ``"``. Show us what string are you trying to achieve, please. – Joelty Mar 15 '19 at 10:14
  • So as file name to select directly exePath? It calls EPLAN but probably without arguments... It just display error message about missing some XML file... – Jan Daliba Mar 15 '19 at 10:23
  • Whole command should be this: "C:\Program Files\EPLAN\Platform\2.7.3\Bin\Eplan.exe" /Variant:"Electric P8" /NoSplash /Frame:0 /Auto /Quiet partslist /TYPE:EXPORTFROMSYSTEM /SQLFILTERPART:1=1 /FORMAT:IXPamImportCSV /CFGFILE:"D:\EPLAN\1_MASTER_DATA\Data\Artikl\EPLAN_CZ\csvimportexport - RMT.cfg" /EXPORTFILE:"C:\Users\dlb\AppData\Roaming\EPLAN_Custom\export.csv" – Jan Daliba Mar 15 '19 at 10:38
  • @JanDaliba - Please add that to your question and not in a comment! – Chris Dunaway Mar 15 '19 at 14:42

0 Answers0