Obs.: The string in the path/code \xyz\
, can be edited to \RealNameFolder\
. Would it be necessary?
Considering:
- Yours
*.s11
files are in the Dump
folder:
D:
|
\---Dump
0001.s11
0005.s11
0010.s11
0015.s11
- The folder for creating the
flash.mtb
file is \Dump
D:
|
\---Dump
0001.s11
0005.s11
0010.s11
0015.s11
flash.mtb
- The
createAndDump.cmd
file is one level before the \Dump
folder:
D:
|
| createAndDump.cmd
|
\---Dump
- The
C#
executable and createAndDump.cmd
are in the same folder:
D:
| createAndDump.cmd
| RunBat.exe
|
\---Dump
- Use c# code suggested below to get the work directory where the executable is running, and use this to try call the bat:
string pathdir = Directory.GetCurrentDirectory();
var process = new Process();
var startinfo = new ProcessStartInfo(Path.Combine(pathdir, "createAndDump.cmd"));
- Can you please try to use the suggested c# code, to also signal you (producing a bat output), where it is easier to check what you have wrong, whether in your c#, or in the execution of your bat?
process.OutputDataReceived += (sender, argsx) => Console.WriteLine(argsx.Data);
using System;
using System.IO;
using System.Diagnostics;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string pathdir = Directory.GetCurrentDirectory();
var process = new Process();
var startinfo = new ProcessStartInfo(Path.Combine(pathdir, "createAndDump.cmd"));
startinfo.RedirectStandardOutput = true;
startinfo.UseShellExecute = false;
process.StartInfo = startinfo;
process.OutputDataReceived += (sender, argsx) => Console.WriteLine(argsx.Data);
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
}
}
}
cmd# code:
You can try using cd /d "%~dp0"
, also use default Program files
(ProgramFiles
, ProgramFiles(x86)
, %ProgramW6432%
) folders, to try find and get the full path to your \Memtool.exe
file:
@echo off && setlocal EnableDelayedExpansion
cd /d "%~dp0" && pushd .\Dump && >"%~dp0Dump\flash.mtb" (
echo\connect && for %%i in (*.s11)do echo\open_file "%%~fi" && echo\select_all_sections && echo\add_selected_sections
echo\program && echo\disconnect && echo\exit ) || echo. Yes, something is very wrong here... && endlocal && goto :EOF
popd && (for %%i in (ProgramFiles,ProgramFiles(x86^),ProgramW6432)do if /i defined %%~i 2>nul (for /f tokens^=^* %%M in ('
%__APPDIR__%where.exe /r "!%%~i!\xyz\Memtool 4.7" "IMTtool.exe"')do echo/%%M|%__APPDIR__%findstr.exe /ei xe>nul && (
pushd "!%%~i!\xyz\Memtool 4.7" && "!%%~i!\xyz\Memtool 4.7\%%~nxM" "%~dp0Dump\flash.mtb" && endlocal && goto :EOF )))