Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
The issue becomes that most of these Bat 2 Exe programs have is that they are just self extracting executables. Many of them extract themselves to the Windows or Users Temp folder. So if the batch file needs to look for a file in that location it is not going to find it because the working directory is now the TEMP folder and not the folder you need to process.So if you are looking to see if a file EXISTS, it is checking to see if it exists in the TEMP folder.I believe Salmon Trout did a right up on this very affect in a previous thread a couple of days ago.Remember that SETX is not native to Windows XP. That is part of the Support tools. It may not be loaded on every person's computer that needs to run the batch file.
and the if exists statement is NOT looking for filenames, it is looking for folders/directories
That is irrelevant. My original statement still holds true.
how does the exe batch file uncompressing itself to a temp folder override my explicit path set for the environment variable "return"??
i have a few .cmd files that i would like to compile for distribution on other computers.
This thread just goes to prove what I (and others) have said before, namely that batch-to-exe converters are a bad thing, and not for any serious work. The first question that comes to mind, is why bother to hide the batch script? If the answer is "to hide my code from the prying eyes of people who might want to steal my ideas", then my answer would be "If you are still at the level of batch scripting, then your ideas are almost certainly not worth stealing". Many people, when presented with an .exe file of unknown origin, wonder "what does this thing do?" If the answer from the supplier is "I'm not going to tell you, and I have deliberately hidden the code" then that is a warning sign straight away. Also the use of setx makes me wonder just what the *censored* is going on. If the motivation is to make something that looks "professional" then just dressing a batch file up with a wrapper is not going to do this. There are plenty of compiled languages which are free and can make exes. C, C++, FreeBasic, there are a ton of them. Even Auto-It can make an exe file. If you want to make a proper program, put in the effort with a proper language.Now to some specifics: all that most batch-to-exe converters do is create a self-extractor that spits out the original batch file into a convenient folder (usually the current user's temp folder) and then runs it from there. Therefore anything that expects to find folders and files that are defined as relative to the .exe file or its folder is not going to work. Secondly, some of those converters are for MS-DOS which is not the same as Windows NT family command prompt. I notice that Quick Batch Compiler is payware, so did you pay for this or is a cracked version? BatLite is MS-DOS only. So is bat2exec. Batch File Compiler PE is payware, so again did you crack it? (You sure have listed a lot of payware there!) Batch Compiler v3.1.2 needs a runtime: .NET Framework v1.1. The "compiler" is written in C# .NET and as such requires the .NET runtime to run. Bat to Exe Converter is free, exescript is payware, so is powerbatch. Batlite and Bat2Exec produce 16-bit .com executables which will not run on 64 bit operating systems.
Put an ECHO %CD% in your batch file and put a pause after it, then compile it to an exe and run it and tell us what is output.
Either merge them all into one .cmd file and distribute that, or zip them up. A Batch "Compiler" (which there really is no such thing, as far as I've seen) will not really help with your particular issue, which is one of packaging. In fact, as Salmon Trout points out, many of the so-called compilers will add additional required components in order for a system to run the "compiled" result, such as the .NET framework. And of course if it generates a executable that executable will typically have it's own requirements; it could be 32-bit or 64-bit, which could change the assumptions made by the batch or it could in the case of a very old "compiler" be 16-bit, assuming it is able to "compile" at all.I've been putting "compile" in quotes because it seems that there is a rather wide misconception that anything that turns one thing into an executable is a "compiler" but the definition is more or less that the program turns one set of instructions into another set of instructions. In the case of C/C++, the compiler turns C/C++ code into machine code for running on a given processor architecture, or even P-Code for running in the appropriate P-Code interpreter, which is often built-in to the program. C#/VB.NET compiles to IL, Java compiles to Java Bytecode, etc. But no Batch compiler I've seen actually does this- they all simply package up the batch file inside a wrapper executable and call it the "compiled result" when all it really does is extract the contained Batch file and execute it using the system, as normal. All it really does is add size and additional requirements to the batch file, as well as introducing any number of gotcha's based on broken assumptions, which Salmon Trout has gone through quite thoroughly before.For your purposes, I reiterate my suggestion that distribution should be simply distribution of the .cmd files. If you need it all in one file, use a zip file, or even a self-extracting zip file. "compiling" to a executable will merely compound your problems.
what i meant to say was that i have individual files that need compiling
If you are asking what other high-level language would be the easiest to port to, well... none of them. You would end up rewriting it from scratch anyway, which makes the question sort of moot.
Not entirely true. Powershell will still recognize most batch commands.
Also allows you to utilize VBScripts within the same "program."
Might be the only other language available that would allow some porting options from batch.
Still, the OP may be much better off utilizing an actual programming language to accomplish whatever tasks that are needing accomplishment.
Or you could always reasearch and try writing your own program in machine language as well. Talk about efficiency. You take out the compiler aspect completely. Of course it will likely only work for your particular chipset, but it will work nonetheless.
Yes I was being facetious with that last comment. I mentioned it because I recall a homework assignment that had us do the machine code for an 8088 chipset that would assign two variables, add them together, and output it to the screen. It was ridiculous the amount of work that went into that. I was just happy that we were able to write it in hex rather than binary.
I suppose the more correct term would be to say a programming language designed to output .exe files.
For Powershell, I haven't actually dabbled too much into it, and yes the stuff I did dabble in was a pretty trivial batch file. Powershell documentation had either the implicit or explicit connotation that many batch commands worked just as well in Powershell, or perhaps that the batch functionality was still supported through Powershell. It's been awhile, so I'm not certain.
You have been very helpful in teaching me to stick with what I know and not to talk about the things I don't, as that's when the beatings start. You have effectively paddled me in front of the school assembly, so I will now lick my wounds and live to program another day.
OK, but why do you need to compile them?
skorpio07, we keep asking you:
Not entirely true. Powershell will still recognize most batch commands. Or you could always reasearch and try writing your own program in machine language as well. Talk about efficiency.
This can be useful so that if something comprises of several batch files, rewriting them in powershell could be done top down, and the powershell can call batch files, until those batch files are rewritten in powershell.
The real need for comiling was for speed and not much else.
I am sure you are aware now of why it wasn't speeding it up but actually slowing it down.