Question

I need to know how I could make a batch file that would execute a dll file as if it was an exe does any one know what I could do I am using windows 7. The file is an exe just with the dll extension.

Was it helpful?

Solution

If i understand it, you have a myProgram.exe file renamed as myProgram.dll and want to run that executable.

If this is the case then all you need is to directly invoke the file. To test, from command line, from the same directory where the file is, type myProgram.dll and it will execute. The OS will identify the file as executable an run it.

If you want to execute the program from another directory, and you supply the full path to the executable, it will also work.

BUT if you want to call the executable from another directory without indicating the full path to the executable, using the PATH variable to locate the program, it will not work.

When a program is search over the folders indicated in PATH variable, the content of variable PATHEXT determine the extensions of files to search in PATH folders. And .dll is not in this list.

So, or you indicate the full path to the executable (absolute o relative) or include the .dll extension in the PATHEXT variable before calling your executable.

OTHER TIPS

If the DLL is a .NET assembly it could be rather easy. For instance, a .NET dll may be accessed from batch file (via) powerhshell like this.

cmd /c start /b Powershell -command "[System.Net.Dns]::GetHostByAddress('8.8.8.8')" 

That would allow you to access the .NET system DLL that handles the DNS namespace and call it's methods directly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top