how to protect batch source code? - batch-file

OK so I tried to convert bat to exe using many programs but at the end all of them just put the bat files in temp folder so I wonder if there is another way to protect the code
I thought is there a way to delete that bat from the temp folder after executing the exe file ?
I even thought is there a way to make the exe to put the temp bat in memory ? I heard that its possible but I don't how to do this
any Idea
I want this because I gave a sample exe(that di half the work) file to a client to test it and then pay for a program that I put a lot of hours on it , but after 2 days he answerd me that he isn't interested so I think that he did get he source code

After a bit of searching I found this which is a batch script that uses 7-Zip to compile the batch into an exe. It will still dump it out into %temp% but it does say that it removes all the temporary files once it has finished, which you said you would like.
You other option would be to re-write the code in a proper programming language like C or C++. Although it might not be impossible to decompile the code I don't think anyone would bother trying!

You can also make it delete itself after it is done.
See this answer to How to make .BAT file delete it self after completion?

Related

Is it possible to embed an executable inside a batch file?

There are many programs which help me write more efficient code (NirCmd etc.), but they can't run properly if they aren't installed in the computer. So is there a way to, for example, in the temp folder, extract the program from a batch program and use it.
I tried reading the executables with a hex editor, putting the hex code into another file and saving it as an executable. But this failed. So, is there any way to efficiently store an executable inside a batch file, create it and then run it?
Yes, there is one that I know of and works perfectly.
It is a program called bhx.exe (link to its site here).
It can also embed other file types.
The usage is quite simple:
(optional) Create a cabinet (.cab) file from the original .exe using this command: makecab yourexe.exe yourexe.cab. For better compression you can use the /D switch in this way: makecab /D CompressionType=LZX yourexe.exe yourexe.cab
CD to the directory bhx is in and do this: bhx yourexe.cab. Other switches are described in the website.
There you go, the mybin.cmd file is generated.

How do I search into an .exe file to recall a file in batch

This may seem a bit ironic, but I am currently working on a 250$ kit, and I hoped to program in batch. (It's a long story, alright?) HOWEVER, I want to compile my source code into an exe, but because it has so many dependencies, and I mean a lot, (At the very least, minimum dependencies is 4 without having someone create more), and I'd like to modify ONE of them and run the other two(If it helps, it is a text document, and three cmd files) while running the program, is there a way I can add these into the primary .exe file and have the .exe file(PROGRAMMED IN BATCH) read, run, and modify the files I add in, or do I have to leave them separated? Basically: Bootstrap as the executable, a screen.cmd and backlogger, and then a .txt file. It's... complicated on how to explain it. (Sorry if I may seem a little off hand, I've got issues attempting to keep myself on one track most of the time)

How to copy the names of the subfolders in a folder, so to use them in a batch program (command line)?

I need to check the files of a versioned system. To do that, I need to write a batcha program so to compare the contents of several folders containing the repositories.
So, my question is: how can I "read" the names of all the subfolders inside a folder, so to use these names later to find subfolders having the same names in a different repositories?
I suppose I may use DIR to print on the screen a list of these names but I don't know how to write it on a text file and then read it. Moreover, I should edit this kind of list, anyway.
Any suggestions or new ideas to solve this problem?
I thank gratefully who ever will answer.
it seems that you can get the subfolders using batch file from perl as follows:
system("start C:\\Temp\\mybatchfile.bat");
or you might try to pass your command suggested by #Stephan straight to system and try to handle what it is returned.

Copying multiple files to a Winscp directory via Script

I have a problem when trying to upload multiple files to one WinSCP directory, i can manage to copy just one single file, but the problem is that i need to upload many files that are generated by a software, the names are not fixed ones, so i need to make use of wildcards in roder to copy all of them, i have tried many variants on the code, but it all was unsuccessful, the code i am using is:
open "sftp://myserver:MyPass#sfts.us.myserver.com" -hostkey="hostkey"
put "C:\from*.*" "/Myserverfolder/Subfolder/"
exit
This code does actually copy the first alphabetically named file, but it ignores the rest of the files.
Any help with it would be much appreciated
Try this in script
Lcd C:\from
Cd Myserverfolder/Subfolder
Put *
Try and do all manually first so you can see what's going on.

Watcher batch file for .txt cloning/reseting/modification

I am trying to create a batch file that works something like a watcher, here is what I am trying to do:
The batch keeps monitoring a .txt file for any modification.
Once the file has been modified by any reason, the batch file proceeds with its function.
The function can vary, either change/replace/delete a line of text inside the file or replace the actual .txt file with a previous clone of it.
After this it keeps monitoring, the cycle repeats itself to prevent the file from being modified.
I do not understand anything of batch, I have tried to find guides and ways of doing it but I am really confused so if anyone could help me with this (a guide explaining how to or the actual final batch) I would be very grateful.
Thank you for your time and patience!
Batch file article on Wikipedia will give you enough information to start understanding batch files.
There is a basic example with explanation that will be helpful getting started with running batch file.
Also take a look at the resources mentioned at the Stack Overflow Batch tag info
Once you know how to write batch files, look for commands that you will require to complete your task.

Resources