0

I was getting 'jlink' is not recognized as an internal or external command when trying to run a command from a batch file. The batch file runs fine on its own, from command prompt. I've checked the path to the application and can see it in the PATH setting.

However, I added echo %path% to my batch file and the application doesnt appear in the output...

How I'm launching the bat file...

    public bool Execute(string batchFile)
    {
        var processInfo = new ProcessStartInfo();
        processInfo.WorkingDirectory = programmersPath;
        processInfo.FileName = programmersPath + batchFile;
        processInfo.RedirectStandardError = true;
        processInfo.RedirectStandardOutput = true;
        processInfo.UseShellExecute = false;

        var process = Process.Start(processInfo);

My user PATH setting...

enter image description here

Batch file...

echo %path%
jlink 

Last few lines from the path output... (i'm not pasting the whole thing but jlink is not there)

C:\Users\rober\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files (x86)\mingw-w64\i686\mingw32\bin

EDIT

I am writing a WinForms app and launching it from Visual Studio. I'm not doing anything with users/permissions. Visual studio is launched as my user, not as Admin.

when I run echo %path% from cmd I can segger is in there.

I'm clearly missing something, I just can't see what.

TedTrippin
  • 3,525
  • 5
  • 28
  • 46

1 Answers1

0

After frantically googling every combination of how to access environment variables and forward them onto the spawned process eventually the problem went away after restarting my laptop!!! Normally, I just close it instead of shutting down.

It appears, despite installing the jlink software a fortnight ago, only a complete restart fixed this problem. I could have sworn I performed an update-and-restart more recently than that but can't be 100% sure.

TedTrippin
  • 3,525
  • 5
  • 28
  • 46