Search code examples
windowsbatch-filecmdwgetcopy-paste

How to automate cmd bat file to execute command as we paste text?


I am working with wget here. What I want to do is fetch the links as I paste in cmd so that it makes it easy for me not to re-write each line with the links I want wget to fetch.

The common/simple code (in batch) for fetching a website link data is "wget "http://example.com/example" --no-check-certificate" or "wget http://example.com/example --no-check-certificate" (both works in .bat), but I want it to be something like "wget %paste --no-check-certificate" so that if I paste the link say https://google.com in the command prompt it directly runs is as "wget "https://google.com" --no-check-certificate". How do I achieve it?

I have tried the normal batch file scripting with the code wget "http://example.com/example" --no-check-certificate, nothing else.

This code works flawlessly in the .bat file:

wget "http://example.com/example" --no-check-certificate

I explain my query in simple steps:

  1. I need a piece of code for batch file that will run the cmd and put it on standby i.e ready for code execution.
  2. I will be pasting links via the right-click > paste method.
  3. I want the bat file/cmd to execute the code with the link embedded as wget http://example.com/example --no-check-certificate where http://example.com/example is the link I pasted in cmd.

Solution

  • Execute the following batch script.

    @echo off
    :loop
    set /p "link=Paste Link "
    wget "%link%" --no-check-certificate
    goto :loop
    

    set /p is intended for user input. It also accepts a "paste".