clink icon indicating copy to clipboard operation
clink copied to clipboard

Clink not injected for batch files (bat/cmd)

Open ferenczy opened this issue 6 years ago • 7 comments

When I open cmd.exe, Clink is properly injected and executed (using the AutoRun registry key).

But when I directly run a batch file (by executing a bat or cmd file), it's not being injected. Is there any way to make it work even for batch files, please?

ferenczy avatar Sep 28 '17 10:09 ferenczy

It has been almost a year since I posted my issue and still no answer...?

ferenczy avatar Jul 26 '18 15:07 ferenczy

bat files are executed by a cmd.exe instance started with a "/c" argument. IIRC, clink will not inject itself in this case. Perhaps changing in the registry how a bat in opened to be explicitly cmd.exe /k "%1" %*

garoto avatar Aug 11 '18 12:08 garoto

Thank you @garoto but I don't need it anymore. Let me explain it:

I had a custom prompt defined in an environment variable or in the registry (doesn't matter where) where I have used ANSI color codes extensively. When I ran a console, Clink injected itself and interpreted the ANSI codes but when I ran a batch, the output was full of "garbage" because of uninterpreted ANSI codes. That's why I was looking for a way to inject Clink to a console started by a batch.

Since I couldn't manage to achieve that, I simply removed all ANSI codes from the prompt defined in the environment variable or in the registry and defined my colored prompt in a Clink's LUA script instead. This way I have a proper monochromatic prompt for batches and colored prompt in the regular console.

If anyone interested, this is my prompt definition for Clink. There are also definitions for a prompt with the same features and look for Powershell, Bash, and Zsh.

ferenczy avatar Sep 24 '18 19:09 ferenczy

I experienced the same issue, at the moment I'm using Clink v1.0.0.a1 (was the same with 0.4.9)

Giova84 avatar Nov 28 '18 21:11 Giova84

I came here to report the same issue, was not going to necro this thread, but .. seeing someone just a day ago so I do not feel as bad. The change above "cmd.exe /k "%1" %*" do you have the key location available ? Would save me a bit of time looking. I tried shortcuts and a few other this with no luck. Thank you,

MattBushey avatar Nov 30 '18 08:11 MattBushey

2018-11-30 03_51_55-bushey matt 1 - teamviewer - free license non-commercial use only

I made a mistake on syntax, it does seem to work this way

It seems to work, but the settings are not being applied that work in another window using START CALL blahblah.bat I will play with it some more

Here are some pictures, I can create another case/thread if feeling the need but since stemming from the change above I figured I would continue from here manually starting things and going /C then doing it that way it works. When add in the /k although shows it attached settings dont seem to apply.

I am sure this is user error, me being that user but some guidance and a tip or to would be helpful.

2018-11-30 04_01_49-bushey matt 1 - teamviewer - free license non-commercial use only

After I CTRL-C in the most forefront window (the one creating mutations for my fuzzer) I am left with the CTRL+C. 2018-11-30 04_03_29-bushey matt 1 - teamviewer - free license non-commercial use only

I then "X" it out and again I am left with the CTRL+C. In the background towards the left you will see the option 2. If I run START CALL cmd.exe from the batch file and then run CLINK SET, I again get the same settings. 2018-11-30 04_06_25-bushey matt 1 - teamviewer - free license non-commercial use only

Perhaps I am not understanding the functionality but I was under impression these would be suppressed.

Thanks

MattBushey avatar Nov 30 '18 08:11 MattBushey

Hello guys, I'm actually trying to achieve this for Robot Framework in a Jenkins pipeline. It's working locally if I manually start command line and then execute my .bat file. But if I execute first my .bat file It does not work... I don't see how I could setup my windows to load clink before the .bat script... I tried: start cmd.exe /k "my_bat_file.bat" It does not work...

Do you know if there is a workaround to use clink with Jenkins?

gigi199596 avatar May 03 '19 15:05 gigi199596