0

I am using cURL.exe file in my batch file but the problem is users should not get to know what mechanism I am using to pull and display data from website.

Now How This is Working: We have to place cURL.exe file under C:\ so that my batch file will use this to connect to WAN server and pull the data.

What I am expecting: I need to merge / attach cURL.exe into my batch file so user don't have to copy the cURL file to C:\ location for my batch to execute.

Finally I will be converting batch file to exe, is there a way we can merge cURL.exe and my.bat file together and copy the cURL.exe into the desired location?

Many thanks...

manjesh23
  • 369
  • 1
  • 4
  • 21
  • 2
    Possible duplicate of [Store a file inside of a batch file?](http://stackoverflow.com/questions/19575665/store-a-file-inside-of-a-batch-file) – python必须死 Aug 31 '16 at 02:52

1 Answers1

4

You can do the following (based on an answer here):

Create one file batchBin.bat with the following contents:

;;;===,,,@echo off
;;;===,,,echo Do something here
;;;===,,,findstr /v "^;;;===,,," "%~f0" > curlEXTRACTED.exe
;;;===,,,echo YOU CAN ADD YOUR CODE FROM HERE
;;;===,,,curlEXTRACTED.exe example.com
;;;===,,,echo YOU CAN ADD YOUR CODE UNTIL HERE
;;;===,,,exit /b

Very important: after exit /b press enter in order to create a newline otherwise it won't quite work.

Then run the following command (assuming you have curl.exe and batchBin.exe in your current working directory):

copy /a batchBin.bat + /b curl.exe /b combined.bat

Then ship the combined.bat file to your client, who will run it, and it'll extract a file called curlEXTRACTED.exe (of course you can change its name in the script) to the current working directory (you can also change its location, if you want to use other path). My version of the script even tests curl by getting example.com, so you can see it works..

Community
  • 1
  • 1
ppp
  • 522
  • 3
  • 18