Copy line to clipboard in Windows Command Prompt

256 views Asked by At
@echo off
cd C:\Users\"%username%"\Downloads\vanity\gen
@echo off
set /p Address=""
vanitygen -X 0 1%Address%
@echo off
for /f "tokens=2" %%a in ('vanitygen 1%Address% ^| findstr Privkey ') do echo %%a|clip
msg "%username%" Generation complete! Your private address has been copied to your clipboard!
PAUSE

This code works, however instead of copying the privaddress, it runs the script again, and copies that code. I need it to copy the first result, not the second one, as they will both be different. What can be done to make it only copy the one displayed?

1

There are 1 answers

0
Magoo On
@echo off
for /f "tokens=2" %%a in ('vanitygen 1%Address% ^| findstr Privkey ') do echo %%a|clip&GOTO DONE
:DONE
msg "%username%" Generation complete! Your private address has been copied to your clipboard!
PAUSE

It's difficult to figure out what you mean by "it runs the script again" - You havent indicated what vanitygen is, but if the string Privkey occurs more than once in its output, this change should fix the problem.